Regex match/replace problems using BRU 2.2.8.0

A swapping-ground for Regular Expression syntax

Regex match/replace problems using BRU 2.2.8.0

Postby litefoot » Thu Dec 29, 2005 10:16 pm

I'm using Windows XP with SP2 and BRU 2.2.8.0

I'm probably missing something but would like to to know if anyone else has had similar results using regexs with BRU 2.2.8.0.

For example a match pattern of (NGC ) and a repace pattern of \1 causes V 2.2.8.0 to flag every selected file as matched regardless of whether the match pattern is in the file name or not, drops the first character, and shows 4 characters as the replacement for renaming.

m57ring_hst_big.jpg becomes 57ri.jpg
NGC 1499 Cal Pers.jpg becomes GC 1.jpg

BRU 2.2.7.0 performs as expected matching the second file and renaming it as follows.

m57ring_hst_big.jpg will not be matched or changed and
NGC 1499 Cal Pers.jpg becomes "NGC "

Another example. A match pattern of (NGC )(\d{4}) and a replace pattern of \2 \1 causes BRU 2.2.8.0 to not flag any selected file name as matched even though the match pattern is in the file name. File name NGC 1499 Cal Pers.jpg should be matched but it is not. BRU 2.2.7.0 properly matches this file and makes the proper rename to 1499 NGC .jpg.

Can anyone help me on this problem?

Thanks in advance


litefoot
litefoot
 
Posts: 3
Joined: Thu Dec 29, 2005 9:21 pm
Location: San Antonio, TX

Postby Admin » Fri Dec 30, 2005 12:19 am

Hi litefoot,

Please could you give me some concrete examples, including results, showing the differences between BRU 2270 and 2280. There were some changes made to the RegExp logic when making BRU unicode-compliant, so I want to make sure I didn't break anything. (I got virtually no feedback from the beta so I wasn't able to tell).

What I'd like is filenames and expressions, so that I can create filenames with the same name and then debug the different versions.

Your help is appreciated.


Jim
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Postby litefoot » Fri Dec 30, 2005 3:42 am

Hi Jim. Thanks for the response.

Here are some actual file names and results. Please don't read an ultimate aim into the regex patterns. They are given here only to allow you to recreate the results I get. Hope this helps.

Actual file names. All files were selected for each test begining.

IC 2118 Witch Head.JPG
M42 Orion.jpg
m57ring_hst_big.jpg
N 1 Small Magellanic Cloud.jpg
NGC 1499 Cal Pers.jpg
NGC 2237 Ros Mon.jpg
NGC 3132 Eight-B 1.jpg
Simeis 147 toward Taurus.jpg
Tarantula nebula LMC.jpg

---------------------------
Version 2.2.8.0

Match Pattern; (NGC ) - NOTE space after NGC.
Replace Pattern; \1

Rename results

C 21.JPG
42 O.jpg
57ri.jpg
1 S.jpg
GC 1.jpg
GC 2.jpg
GC 3.jpg
imei.jpg
aran.jpg

Match Pattern; (NGC )(\d{4})
Replace Pattern; \2 \1 - NOTE space between \2 and \1.

No files were matched or renamed even though 3 of them should have been.


---------------------------
Version 2.2.7.0
Same file names used as for version 2.2.8.0 tests.

Match Pattern; (NGC \d) - NOTE: \d added so only regex windows could be used. BTW the \d results in no matches at all using version 2.2.8.0.
Replace Pattern; \1

Rename results which are correct.

IC 2118 Witch Head.JPG
M42 Orion.jpg
m57ring_hst_big.jpg
N 1 Small Magellanic Cloud.jpg
NGC 1.jpg
NGC 2.jpg
NGC 3.jpg
Simeis 147 toward Taurus.jpg
Tarantula nebula LMC.jpg

Match Pattern; (NGC )(\d{4})
Replace Pattern; \2 \1 - NOTE space between \2 and \1.

Rename results which are correct.

IC 2118 Witch Head.JPG
M42 Orion.jpg
m57ring_hst_big.jpg
N 1 Small Magellanic Cloud.jpg
1499 NGC .jpg
2237 NGC .jpg
3132 NGC .jpg
Simeis 147 toward Taurus.jpg
Tarantula nebula LMC.jpg

Thanks again and if any else needed let me know.

litefoot
litefoot
 
Posts: 3
Joined: Thu Dec 29, 2005 9:21 pm
Location: San Antonio, TX

Postby Admin » Fri Dec 30, 2005 4:55 am

Okay, I think I've got to the bottom of this. I can recreate the problem, and after making a small change I can obtain the correct results.

I've uploaded version 2.2.8.1, perhaps you can try it and report back.

Many thanks for your patience and help,



Jim
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Postby litefoot » Fri Dec 30, 2005 6:47 pm

Hi Jim. That was fast!

I think BRU 2.2.8.1 regex is working correctly now. I tried all the examples that failed for me using 2.2.8.0 and they all worked correctly using 2.2.8.1. I even tried other regex expressions, especially using '?' to stop '*' and '+' from being greedy, and they worked as expected too.

Thanks again and good luck.


litefoot
litefoot
 
Posts: 3
Joined: Thu Dec 29, 2005 9:21 pm
Location: San Antonio, TX

Postby Admin » Fri Dec 30, 2005 6:51 pm

Excellent, many thanks for the update. Amazing what you can fix at 4AM when you can't sleep :D

Jim
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Postby Stefan » Sun Jan 01, 2006 9:51 pm

Thank you both.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions