Difference between regular expression in BRU and NPP

A swapping-ground for Regular Expression syntax

Difference between regular expression in BRU and NPP

Postby cbanzet » Tue Aug 13, 2019 6:19 pm

Although I am far from a pro at regular expressions, I'm not a complete noob either. However, all of my experience has been with Notepad++.

I have a list of files that have long strings of zeroes in them:

ch00000000000001-190320-085957-092959-12p00001000000400.264
ch00000000000001-190320-085957-092959-12p00001000000400.avi
ch00000000000001-190515-125957-132958-12p00001000000400.264
ch00000000000001-190515-125957-132958-12p00001000000400.avi
ch00000000000001-190515-185957-192959-12p00001000000400.264
ch00000000000001-190520-095956-102958-12p00001000000400.264
ch00000000000001-190520-095956-102958-12p00001000000400.avi
ch00000000000001-190520-102956-105958-12p00001000000400.264
ch00000000000001-190520-102956-105958-12p00001000000400.avi
ch00000000000002-190812-163030-170032-12p00001000000400.264
ch00000000000002-190812-163030-170032-12p00001000000400.avi
ch01-190320-075957-082959-12p00001000000400.264
ch01-190320-075957-082959-12p00001000000400.avi
ch01-190320-082957-085959-12p00001000000400.264
ch01-190320-082957-085959-12p00001000000400.avi
filelist.txt

I don't want a long string of zeroes when only 1 will do, so I want to replace a string of zeroes with only one.

In NPP, this is simple

Code: Select all
Match:     0+
Replace:     0


This results in the following:

ch01-190320-085957-092959-12p01040.264
ch01-190320-085957-092959-12p01040.avi
ch01-190515-125957-132958-12p01040.264
ch01-190515-125957-132958-12p01040.avi
ch01-190515-185957-192959-12p01040.264
ch01-190520-095956-102958-12p01040.264
ch01-190520-095956-102958-12p01040.avi
ch01-190520-102956-105958-12p01040.264
ch01-190520-102956-105958-12p01040.avi
ch02-190812-163030-17032-12p01040.264
ch02-190812-163030-17032-12p01040.avi
ch01-190320-075957-082959-12p01040.264
ch01-190320-075957-082959-12p01040.avi
ch01-190320-082957-085959-12p01040.264
ch01-190320-082957-085959-12p01040.avi
filelist.txt

This is exactly what I want.

However, if I use the same RegEx in BRU I get:

0.264
0.avi
0.264
0.avi
0.264
0.264
0.avi
0.264
0.avi
0.264
0.avi
0.264
0.avi
0.264
0.avi
filelist.txt

which I most decidely do not want.

To achieve this result in NPP, I would have to do this:

Code: Select all
Match:     .*?0\.
Replace:     0\.


So far I haven't hit on the magic combination in BRU to achieve what I want (but I'm sure I will get it eventually).

My questions are:

    A. What is the correct BRU RegEx (in case someone answers this before I figure it out)?

    But most importantly

    B. Where do I find documentation on the RegEx language for BRU?

    C. Why is there a difference between the two?

Just in case anyone is interested, this is my bible for RegEx in NPP,

https://letconex.blogspot.com/2013/06/how-to-use-regular-expressions-in.html

but, obviously it has limited use in BRU.
cbanzet
 
Posts: 3
Joined: Tue Jun 20, 2017 6:53 pm

Re: Difference between regular expression in BRU and NPP

Postby therube » Wed Aug 14, 2019 1:59 pm

One way to do it (though it's not "clean")...


3:Replace, Replace 00 With 0
Rename

- toggle the checkmark in 3:Replace
Rename
- toggle the checkmark in 3:Replace
Rename
...
(repeat until there is nothing more to rename)

---

BRU states that it uses the PCRE library for regex.
(Everything also works fine using Match: 0+ Replace: 0)
therube
 
Posts: 693
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions