Remove Duplicate Underscores

If you need help on how to use the program
Post Reply
nixuser
Posts: 3
Joined: 2010-06-20 00:00:43

Remove Duplicate Underscores

Post by nixuser »

Hello,
I have just started using Ant Renamer. I am at the point where I have all special characters and spaces removed. Those characters have been replaced with underscores.

Now my question is how do I get ride of the "duplicated" underscores.

I have tried:

search: _\+ replace: _
search: _$+ replace: _

PS: Not sure if I would use those actions in:
1) String replacement
2) Multiple string replacement

Any help would be greatly appreciated.

Regards
nixuser
Posts: 3
Joined: 2010-06-20 00:00:43

Post by nixuser »

Figured it out!!!!


1) "Multiple String Replacement" just replaces strings and assumes its a global replacement on the file name. It seems to take everything entered literally; no regular expressions.

2) Not sure about "String Replacement". I think it's only a one shot global; not 100% sure on that one.

3) If you want to condense repeated characters from the Multiple String replacement; those actions are preformed under the "Regular Expression" section. I wish you could save more that one item in that section; like under "Multiple String Replacement". Haven't tried creating one long RegEx yet.

Keywords: Duplicates characters, Remove Duplicates, Remove Duplicate characters.

Hope this helps someone.
nixuser
Posts: 3
Joined: 2010-06-20 00:00:43

Post by nixuser »

PS: The confusing thing in the help file listed under "Regular Expressions":

"New name, containing the new name of the file, with $nn backreferences (nn being a number) to indicate where found strings have to be inserted. Note: these backreferences are presented with "\" instead of "$" on the syntax page mentionned above. "


I was using a Dollar sign for for repeat characters. The solutions is entered in the "Regular Expression" section:

Expression: _{2,}
New Name: _

The help file isn't clear where you would use the dollar sign $ as a back reference (string replacement, multi-string replacement, regex section or some other section). Also, since the $ is EOL character; how and when do you escape it? BRE, ERE examples for various sections in the "Actions" side bar would be helpful.

I think there is probably more to Multiple String Replacement. Seems like there might be more than one RegEx engine at work or the settings are different between each section.

I was trying to doing a sed style replacement: sed 's/_\+/_/g'

PSS: Not sure if this RegEx engine is BRE or ERE. Syntax from the above: _{2,} indicates that this is ERE. Not sure if 1 or both are supported; haven't tested it out.

Sorry about being wordy; hope fully this helps someone.

Keywords: BRE, ERE, Basic Regular Expression, Enhanced Regular Expression, Replace duplicate characters, Condense Duplicate Characters.
antp
Site Admin
Posts: 9665
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Regular expressions can be used just in the "Regular expression" action, else what would be its purpose :p
Other actions are for general users, as the use of these expression is more complex.

Back references are used when you need to reuse the found expressions, here if you just want to delete things (replace by nothing) you do not need back references.
Escaping is done with \
Multiple string replacement is just a basic text search & replace, done on several values instead of one, but it does not involve any special parsing (no regular expressions there).

I am not sure about BRE or ERE, but from what I just read about that it seems that it is ERE.

Sorry for the late answer.
Post Reply