Help with How to Remove Not Quite All Underscores

A swapping-ground for Regular Expression syntax

Help with How to Remove Not Quite All Underscores

Postby Saml214 » Tue May 08, 2018 6:31 pm

Hi All.

I am trying to reapply a naming scheme.

The names could be in any form but most of the file names are:

Word_words_words_MM.DD.YYYY

They may be of a varying number of words and underscores, not all of them are capitalized.
How would I remove all of the underscores and Title Case(with no spaces) something of any number of words, but keep the final bits?

"_MM.DD.YYYY"
and:
WordWordWordWordWord_MM.DD.YYYY

for a title with x-amount of words
-Cheers
Saml214
 
Posts: 1
Joined: Tue May 08, 2018 6:20 pm

Re: Help with How to Remove Not Quite All Underscores

Postby Admin » Wed May 09, 2018 12:54 am

So, remove all _ but the last one? It can be done in one pass with a Javascript function in BRU if you have a commercial license.
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Help with How to Remove Not Quite All Underscores

Postby therube » Wed May 09, 2018 4:48 pm

A little bit of a round-about way ...

1:RegEx
Code: Select all
Match:  (.*)_(.*)
Replace:  \1^\2

this idea here, is that the ^ character is to some "unique" character, i.e., not otherwise used in your file names

3:Replace
Code: Select all
Replace:  _
With:  {space}


4:Case -> Title

5:Remove
Code: Select all
Chars:  {space}


Do the Rename.

You should be left with, "WordWordsWords^05.09.2018"

Then go back & do:

5:Replace
Code: Select all
Replace:  ^
With:  _


Which should give you, "WordWordsWords_05.09.2018".
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions