I am having troubles making my regex-statement to work as intended.
Regex statement: ([a-z][a-z\d] )(?=([A-Z][a-z\d] ))
Starting string: regex2Hard4Me
current result: REGEX2_HARD4_ME
desirable result: REGEX_2_HARD_4_ME
Any help is highly appreciated.
CodePudding user response:
You can match a single char a-z or digit, and assert a char A-Z or digit to the right:
[a-z0-9](?=[A-Z0-9])
In the replacement use the full match followed by an underscore.
Output
regex_2_Hard_4_Me
Then uppercase the string to get REGEX_2_HARD_4_ME