Regex doesn't work

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Regex doesn't work

Postby ap86 » Tue Jul 03, 2012 2:24 am

I can't get regular expressions to work correctly.
Even the simplest of regex either doesn't work at all or works in a completely unexpected manner.

For example,
Match: \d
Replace: x
selects the entire string, including non-digit characters, and replaces it with one x.

Match: [a-z]
Replace: x
does the same.

.* doesn't seem to work at all.

Am I doing something wrong here? Tried this with both the 32 and 64x versions.
ap86
 
Posts: 4
Joined: Tue Jul 03, 2012 2:16 am

Re: Regex doesn't work

Postby Stefan » Thu Jul 05, 2012 8:04 am

ap86 wrote:Am I doing something wrong here?


apparently yes
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Regex doesn't work

Postby ap86 » Thu Jul 05, 2012 8:46 am

Anything I could provide that would allow you to be a bit more helpful?

Edit: Here's a screenshot. I'd expect the "000" to be changed to "111". Image
ap86
 
Posts: 4
Joined: Tue Jul 03, 2012 2:16 am

Regex work perfectly

Postby Stefan » Thu Jul 05, 2012 9:31 am

>Anything I could provide that would allow you to be a bit more helpful?
A few "before/after" real world example file names in plain text will do always :)


To your case:

Please note for the BRU regex engine:
1.) you have to match the whole string "unins000" and store the parts you don't want
to modify into (...) and refer to them in the replacement by using \1.

2.) every regex expression match exactly one single sign. So \d will match exactly one single digit only.


So try...

FROM:
unins000.dat
TO:
unins111.dat

DO:
RegEx(1)
Match: (.+)\d\d\d
Repla: \1111

OR
Match: (.+)\d{3}
Repla: \1111

OR
Match: (.+?)\d+
Repla: \1111

OR...

You have to know RegEx, AND how the regex-engine of the current app works, if you want to use it and before blaming others for not working :D
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Regex doesn't work

Postby ap86 » Thu Jul 05, 2012 10:15 am

Oh. Admittedly, I feel kind of stupid now. I knew I had gotten it to work before, but after having not used it for a while I forgot. I was doing it like I would in Notepad++. Thank you very much for showing me. Cheers.
ap86
 
Posts: 4
Joined: Tue Jul 03, 2012 2:16 am


Return to BRU Support