Page 1 of 1

How to replace ' @@ , & with an underscore

PostPosted: Sun Nov 07, 2021 7:01 pm
by gregstah
I'm hoping someone can help I'd like to remove the following characters from filenames and directories and replace with an underscore

' @@ , &

I've tried for some time now but have to admit, I find regex extremely confusing.

Using regexr.com I was able to do it as follows:

/@@|,|\s|'/g

I don't know how to implement this in BRU (yes that whitespace is intended.)

Thank you so much :-) spent hours on this without much joy.

Greg

Re: How to replace ' @@ , & with an underscore

PostPosted: Mon Nov 08, 2021 4:44 am
by Luuk
First to put a checkmark inside for "v2", so then the "Match" depends on...

To replace each exact character string ' @@ , &
' @@ , &/g

To replace one, or more repeats of the exact character string... ' @@ , &
(' @@ , &)+/g

To replace each one of the characters '@ ,&
['@ ,&]/g

To replace 1-or-more of the characters '@ ,&
['@ ,&]+/g

Re: How to replace ' @@ , & with an underscore

PostPosted: Mon Nov 08, 2021 5:44 pm
by therube
(Another method.)

3:Replace allows multiple replacement sets (by inserting an "OR", the | symbol), between sets.

Code: Select all
Match:  '|@@|,|&
Replace:  _|_|_|_

Code: Select all
this'XXX is@@a test,this is only&a test.TXT
->   this_XXX is_a test_this is only_a test.TXT