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()
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
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: