How to match these?

A swapping-ground for Regular Expression syntax

How to match these?

Postby dukes909 » Thu Dec 19, 2013 3:32 pm

First, thank you for this software, it's fantastic!

I'd like to rename many, many files like in the following example:

Code: Select all
- Case #1412 - Baptist Memorial Hospital - Variance.pdf
46 Ridgewood Manor Drive - Case # 1355 - Williams, Anne Tillman - Variance.pdf
108 Hwy 314 - Case # 1139 - Durham, Jay - Special Exception.pdf

(yes the - is intentional in the first filename)

to this:
Code: Select all
1412.pdf
1355.pdf
1139.pdf


Basically, there is a "Case #" followed by a series of numbers somewhere in each filename. They are not always in the same location. All I want to extract is the numbers following the "Case #" and retain the .pdf extension. Would love some help! Cheers
dukes909
 
Posts: 2
Joined: Thu Dec 19, 2013 3:22 pm

Re: How to match these?

Postby truth » Thu Dec 19, 2013 10:15 pm

This matches filenames with Case followed by 1orMore Space or #s, then 4-digits (not 5orMore)
1Regex:
.*Case[ #]+(\d{4})[^\d].*
\1

Its very filename destructive, so I erred on being cautious, creating a backup list may be advised.
Just post back, if you need to be more(or less) specific.

You can always put *case* in your #12Filter to show only filenames with case (to filter others away).
It gives a better display in the right-pane if you have alot of filenames without case you'd rather not see.
You dont need to, the regex is far more specific than that, and wont touch anything besides the match above.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: How to match these?

Postby dukes909 » Thu Dec 19, 2013 10:21 pm

Excellent! Cheers
dukes909
 
Posts: 2
Joined: Thu Dec 19, 2013 3:22 pm


Return to Regular Expressions