regex match/replace works elsewhere but not in BRU

A swapping-ground for Regular Expression syntax

regex match/replace works elsewhere but not in BRU

Postby niconiko » Wed Jan 09, 2019 4:30 am

Though I am a first time user of "BRU" --- quite an impressive and powerful tool --- Regex is not new to me.

Here's an example of the problem...

FILE NAME: No. 1 in C Major02. (a) Prelude.flac

MATCH: \d\d (or, more specifically [0-9]+\. )
REPLACE:[leave this field blank]

RESULTS ON...
... NOTEPAD++: No. 1 in C Major (a) Prelude.flac
... regex101.com: [the "02." becomes hilighted]
... BRU: [no change!]

Further to this example, if in BRU I don't leave "REPLACE" blank...

FILE NAME: No. 1 in C Major02. (a) Prelude.flac

MATCH: \d\d (or, more specifically [0-9]+\. )
REPLACE: WTF

RESULTS ON...
...BRU: WTF.flac
...Notepad++/regex101.com: No. 1 in C MajorWTF (a) Prelude

N.B.:
I of course made sure that, of the many varied BRU functions, only the "RegEx(1)" checkbox was checked, that refresh was tried, that a filename was shown selected, and that even in "Filters(12)" its own "RegEx" checkbox was checked "on" (tried "off", too) and its own refresh button was clicked.
I also ensured to follow BRU's implementation of RegEx, i.e., Perl, according to this forum.
But the BRU result remained the same, i.e., the whole file name becomes replaced.

Pour quoi?

Much thanks in advance for considered advice.
niconiko
 
Posts: 2
Joined: Wed Jan 09, 2019 2:29 am

Re: regex match/replace works elsewhere but not in BRU

Postby Admin » Wed Jan 09, 2019 11:28 am

Once you match, then need to use the Replace part to use that match e.g.
Match: (\d)(\d)
Replace: \1WTF\2

\1 means first match
\2 second match
etc.
Admin
Site Admin
 
Posts: 2579
Joined: Tue Mar 08, 2005 8:39 pm

Re: regex match/replace works elsewhere but not in BRU

Postby niconiko » Thu Jan 10, 2019 12:20 am

Admin, your advise helped me better understand Perl's Regex implementation -- in this case, using \ rather than $ for numbered references.

What finally worked:
FILE NAME: No. 1 in C Major02. (a) Prelude.flac
MATCH: (.+)(\d)(\d)\. (.+)
REPLACE:\1 \4
RESULT ON BRU: No. 1 in C Major (a) Prelude.flac

By the way, anyone's recommendations of online guides that address these implementation differences (e.g., \ vs. $) would also be appreciated.

Thank you.
niconiko
 
Posts: 2
Joined: Wed Jan 09, 2019 2:29 am


Return to Regular Expressions