RegEx Rename fail in 4.3
Posted: 2019 Nov 01, 16:11
The arrival of RegEx for Mass Rename is most welcome, but alas! my first test out of the box was a fail. I tried renaming camelCase to snake_case, and vice versa. Here's what happened:
filename = camelCaseToSnakeCase.txt
regexp = (.+?)([A-Z])
replace with = $1_$2
expected result = camel_Case_To_Snake_Case.txt
result = c_am_el_Ca_se_To_Sn_ak_eC_as_e.txt
The quantifier +? should match unlimited times, until it gets to [A-Z], should it not? Why are letters being grouped in two?
If we add the \L token to get lowercase words, it gets worse!
filename = camelCaseToSnakeCase.txt
regexp = (.+?)([A-Z])
replace with = \L$1_\L$2
expected result = camel_Case_To_Snake_Case.txt
result = _Lc__La_Lm__Le_Ll__LC_La__Ls_Le__LT_Lo__LS_Ln__La_Lk__Le_LC__La_Ls__Le.txt
Is the \L token not supported?
snake_case to camelCase also presents problems:
filename = snake_case_to_camel_case.txt
regexp = (.*?)_([a-zA-Z])
replace with = $1\U$2
expected result = snakeCaseToCamelCase.txt
result = snake_Ucase_Uto_Ucamel_Ucase.txt
Seems the \U token is also a problem.
The RegEx I'm using here is pretty standard - is x2 using its own flavor of RegEx? Am I missing something obvious?
(x2 PRO 4.3.0.0 64-bit running on Win 10 1809)
filename = camelCaseToSnakeCase.txt
regexp = (.+?)([A-Z])
replace with = $1_$2
expected result = camel_Case_To_Snake_Case.txt
result = c_am_el_Ca_se_To_Sn_ak_eC_as_e.txt
The quantifier +? should match unlimited times, until it gets to [A-Z], should it not? Why are letters being grouped in two?
If we add the \L token to get lowercase words, it gets worse!
filename = camelCaseToSnakeCase.txt
regexp = (.+?)([A-Z])
replace with = \L$1_\L$2
expected result = camel_Case_To_Snake_Case.txt
result = _Lc__La_Lm__Le_Ll__LC_La__Ls_Le__LT_Lo__LS_Ln__La_Lk__Le_LC__La_Ls__Le.txt
Is the \L token not supported?
snake_case to camelCase also presents problems:
filename = snake_case_to_camel_case.txt
regexp = (.*?)_([a-zA-Z])
replace with = $1\U$2
expected result = snakeCaseToCamelCase.txt
result = snake_Ucase_Uto_Ucamel_Ucase.txt
Seems the \U token is also a problem.
The RegEx I'm using here is pretty standard - is x2 using its own flavor of RegEx? Am I missing something obvious?
(x2 PRO 4.3.0.0 64-bit running on Win 10 1809)