replace dash with space if between letters

Advanced Renamer forum
#1 : 12/03-21 09:47
jerome
Posts: 3
hello
I'm very newbie at regex and I'm trying to replace "-" in filename by a " " but only if it is between letters and not if there's space or else
ex.
"Room-Camera-Screenshot - Daily.jpg"
to "Room Camera Screenshot - Daily.jpg"
seems search regex is "\w-\w" but not sure and can't find replace string

thank you for help
#2 : 12/03-21 10:34
David Lee
Posts: 1125
Unfortunately the definition of "word character" includes numerical digits and underscore. To match an alphabetical character only (ie a to z or A to Z) strictly you should use the regex [a-zA-Z]. However by default ARen is not case sensitive so [a-z] will be fine provided the "case sensitive" box remains clear.

Read the User Guide at
https://www.advancedrenamer.com/user_guide/regul ar_expresions

Based on the information available in the User Guide...

Replace: ([a-z])-([a-z])
With: \1 \2
Case sensitive: Clear
Use regular expressions: Check

However the User Guide only contains a basic subset of regular expressions so a more advanced solution is...

Replace: [a-z]\K-(?=[a-z])
With: Space only

Here the metacharacter \K is an instruction to omit previously matched characters from the final match and x(?=y) is a "positive lookahead", which means that "x" will only be matched if it is immediately followed by "y".

For a broader introduction to regex see:
https://www.regular-expressions.info/

Bear in mind that there are different "flavours" of regex with differing limitations (for example "PCRE" - as used by ARen - does not support "lookbehind", hence the "\K" workaround above).
#3 : 13/03-21 13:23
jerome
Posts: 3
Reply to #2:
second one works fine, thank you very much for solution and explanations, regex is very interesting and so powerful
#4 : 13/03-21 13:23
jerome
Posts: 3
Reply to #2:
second one works fine, thank you very much for solution and explanations, regex is very interesting and so powerful