Need help with regular expression

A swapping-ground for Regular Expression syntax

Need help with regular expression

Postby jash40524 » Wed Jan 18, 2017 9:00 pm

I'm trying to use BRU and regular expressions to achieve filenames that have to be in a very specific format.

File format is:
24 characters long
First 6 are constant
Next 8 are date in YYYYMMDD format
Next 1 constant
Next 2 file index numbers from 00-99
Last 7 constant.

Initially the files arrive in somewhat varying formats, but I've been able to capture all of that by using:
Match: ^([A-Z][a-z]*)

The replace statement is where I'm having trouble. The first 6 digit constant is simple enough, but moving on to include the formatted date and next constant are where I'm having trouble.

Right now I can get the right final file name, but I've literally had to resort to only using replace for that first 6 digit constant, then using the Custom Auto Date with the next constant included in it, Numbering starting at character 15 to handle the index numbers, and the last 7 constant by naming my folder that and using the Append Folder Name option as a suffix.

In other words, I'm a total rookie, have devised a very ugly method of achieving what I need, but would much prefer something more appropriate, cleaner.
jash40524
 
Posts: 2
Joined: Wed Jan 18, 2017 8:50 pm

Re: Need help with regular expression

Postby JMM » Fri Jan 20, 2017 12:29 am

I would do this without RegEx, since they are done before anything else, making you do ugly stuff like you explain, or requiring two steps.

My suggested method:
* Name (2), select remove. This removes completely the original filename, which I think you don't need.
* In Auto Date (8) select mode Prefix, your choice for Type, and fmt Custom . In custom put xxxxxx%Y%m%dyzzzzzz where 'xxxxxx' are the six constant chars at the beginning, '%Y%m%d' is the YYYYMMDD date, 'y' is the middle constant char between the date and the index, and 'zzzzzzz' are the last 7 constant chars.
* In Numbering (10), select mode Insert, at 15 (so it's put between the 'y' and the 'zzzzzzz'), and pad 2 (so it is always width of 2 digits).

That should do the trick, tell us if you succeed or if you need further help.
JMM
 
Posts: 29
Joined: Sat Jan 25, 2014 12:12 pm

Re: Need help with regular expression

Postby jash40524 » Fri Jan 20, 2017 5:10 pm

You, kind sir, are a genius.

I was already using that date field to put one of the constants in place, but hadn't even considered it for the leading characters for some reason or another. Think I got stuck in the regex frame of mind and just couldn't see the forest for the trees.

Thank you!
jash40524
 
Posts: 2
Joined: Wed Jan 18, 2017 8:50 pm


Return to Regular Expressions