inserting a 0 using a wildcard?

A swapping-ground for Regular Expression syntax

inserting a 0 using a wildcard?

Postby JLWW » Wed Jun 22, 2016 5:39 pm

Hi all,

I'm stuck with the following. I have a number of filenames (varying lengths) that have the following setup:

TIC-(YYYY-MM-DD)_XXXX.pdf
TIC-(YYYY-MM-D)_XXXX.pdf

IE, some of my dates have a single digit for day, and others have a double digit. I'd like to add a 0 before the single digit. It always appears in this format, with a -, then a single digit 1-9, then a ). So I was hoping for a regular expression that would allow me to insert a 0 after the - but before the single digit and the close parenthesis. Is there some way to do this with a wildcard? I'm brand new to RegEx.

Thanks!
JLWW
 
Posts: 2
Joined: Wed Jun 22, 2016 5:33 pm

Re: inserting a 0 using a wildcard?

Postby therube » Wed Jun 22, 2016 7:03 pm

One method:

1.RegEx

Code: Select all
match:  (.*-)(.\))(.*)
replace:  \10\2\3
therube
 
Posts: 316
Joined: Mon Jan 18, 2016 6:23 pm

Re: inserting a 0 using a wildcard?

Postby Admin » Thu Jun 23, 2016 1:46 am

Another way would be to use the Javascript renaming functionality in BRU to parse the date from within the ( ) and then reformat it. You can reformat the date in a myriad of different ways, including adding the day name, a week numbers, zeros etc etc
Admin
Site Admin
 
Posts: 1465
Joined: Tue Mar 08, 2005 8:39 pm

Re: inserting a 0 using a wildcard?

Postby JLWW » Thu Jun 23, 2016 4:50 pm

Thank you so much, this worked perfectly!!!

therube wrote:One method:

1.RegEx

Code: Select all
match:  (.*-)(.\))(.*)
replace:  \10\2\3
JLWW
 
Posts: 2
Joined: Wed Jun 22, 2016 5:33 pm


Return to Regular Expressions


cron