We're a place where coders share, stay up-to-date and grow their careers.
Coming here from Google, I will answer my question using your code, thanks! That's how to replace all words etc. from snake_case to camelCase in all js files in a directory:
import glob import re from pathlib import Path rootdir = "C:\\Users\\Your User\\Your Path" REG = r"(.*?)_([a-zA-Z])" def camel(match): return match.group(1) + match.group(2).upper() for filename in glob.glob(rootdir + "\\**\\*.js"): print(filename) text = Path(filename).read_text() text = re.sub(REG, camel, text, 0) file = open(filename, 'w') file.write(text) file.close()
Coming here from Google, I will answer my question using your code, thanks! That's how to replace all words etc. from snake_case to camelCase in all js files in a directory: