Page 2 of 2

Re: RegEx Rename fail in 4.3

Posted: 2019 Nov 27, 16:40
by nikos
must be because I don't think I can change anything more about it :shrug:

Re: RegEx Rename fail in 4.3

Posted: 2019 Dec 01, 22:26
by hajubu
Hello @nikos , @longfellow

just as a hint for using quoted characters ( \Q , \L ,\U .... \E ) with Mtrace of DEELX :: it works as it should.
here (K.I.S.S) simple sample
pattern: exact match (\Q(a*b)\E)([A-Z]) working on (a*b)AAA result is "___Match!"
pattern: lower match (\L(A*B)\E)([A-Z]) working on (a*b)AAA result is "___Match!"
pattern: upper match (\U(a*b)\E)([A-Z]) working on (A*B)AAA result is "___Match!"

pattern: exact match (\Q(a*b)\E)([A-Z]) working on (A*B)AAA result is "_noMatch!"
pattern: lower match (\L(A*b)\E)([A-Z]) working on (A*b)AAA result is "_noMatch!"
pattern: upper match (\U(a*b)\E)([A-Z]) working on (A*b)AAA result is "_noMatch!"

(I did not all variations for clarity,
It shows however that the "Quoted Characters" works on "Matching-Mode/Input" and not for changing the Output chars ($1,$2,$+)
The main purpose is :: metacharacters can be handled like the common characters
i.e. \Q(a+b)*3\E :: matches "(a+b)*3".
and without quoting :: \(a\+b\)\*3 :: Without \Q...\E, we need to escape each special character.

i.e. Quote (disable) pattern metacharacters from \Q till \E. ( see my samples the grouping brackets () are handled as common characters.


If begins with \U (or \L), ends with \E, it will quote (disable) pattern metacharacters from \U (\L) till \E ,
and all lowercase (uppercase) alphas between them will be turned into uppercase (lowercase)
before "comparison" for matching purpose starts.
See also here the sample figures.

Image
Image
Image
Image
Image
Image
image uploader

Re: RegEx Rename fail in 4.3

Posted: 2020 Oct 05, 11:02
by FrizzleFry
longfellow wrote: 2019 Nov 25, 15:12 Unfortunately case conversion is still a problem.

filename = camelCaseToSnakeCase.txt
regexp = (.+?)([A-Z])
replace with = $1_\L$2\E
expected result = camel_case_to_snake_case.txt
result = camel__LC_Ease__LT_Eo__LS_Enake__LC_Ease.txt

I'm following the instructions here: <http://www.regexlab.com/en/deelx/syntax/bas_esc.htm>
If begins with \L, ends with \E, it will quote (disable) pattern metacharacters from \L till \E, and all uppercase alphas between them will be turned into lowercase."
You can see that the correct characters for conversion are being selected, they're just not being converted. Not sure why there's an extra underscore before the "L".

Same problem with uppercase:

filename = snake_case_to_camel_case.txt
regexp = (.*?)_([a-zA-Z])
replace with = $1\U$2\E
expected result = snakeCaseToCamelCase.txt
result = snake_Uc_Ease_Ut_Eo_Uc_Eamel_Uc_Ease.txt

The \U and \L tokens work fine elsewhere, I can only speculate that it's some peculiarity of the Deelx engine that they don't work here. Perhaps there is some arcane syntax usage I am missing? Sad, as capitalization/decapitalization is a handy feature in a renamer.
I see where the extra underscores are coming from... it's because the \s are being replaced by _ because the rename routine sees them as invalid
I changed the replacement character to dash (-) and I get extra dashes instead
could the backslashes be getting replaced before the regex magic gets done?

Re: RegEx Rename fail in 4.3

Posted: 2020 Oct 05, 15:34
by nikos
whatever the issue is, it isn't in xplorer2. If somebody cares to examine the source code and fix it, it is available here
http://www.regexlab.com/en/deelx/

Re: RegEx Rename fail in 4.3

Posted: 2020 Oct 06, 02:04
by FrizzleFry
hajubu wrote: 2019 Dec 01, 22:26 It shows however that the "Quoted Characters" works on "Matching-Mode/Input" and not for changing the Output chars ($1,$2,$+)
The main purpose is :: metacharacters can be handled like the common characters
i.e. \Q(a+b)*3\E :: matches "(a+b)*3".
and without quoting :: \(a\+b\)\*3 :: Without \Q...\E, we need to escape each special character.
I can confirm this behavior in the DEELx Regex Match Tracer and in the mass renaming tool.

\Q \L \U \E do work in the match field but apparently cannot be used in the replace field.

This is not the case with all regex implementations. For example the PERL regex in awxRename uses

s/([\w']+)/\u\L$1/g

to change all words to Words

match: ([\w']+)
replace: \u\L$1
the g at the end does multiple replace

So it seems we cannot do case conversions with the DEELx regex engine.