Peters Flexible RenAmiNg Kit (PFrank) Forum Index Peters Flexible RenAmiNg Kit (PFrank)
Support and Discussion Site for the PFrank File/Folder Renaming Tool (***NEW HOME PAGE*** "http://pfrank.atwebpages.com")
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with exclusion regex

 
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions
View previous topic :: View next topic  
Author Message
eidolen



Joined: 15 Apr 2008
Posts: 11

PostPosted: Sat Sep 05, 2009 7:10 pm    Post subject: Help with exclusion regex Reply with quote

Haven't been around for a while now so I think I got a little rusty. :\

I'm having trouble creating a regex that would apply to all *unless* it is enclosed by any type of bracket.

ie. change all Underscore marks with spaces unless that underscore is enclosed within brackets. I know I've done similar regex before, but now I'm just stumped.

Any help is much appreciated.

Cheers
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Mon Sep 07, 2009 3:36 am    Post subject: Reply with quote

Hi,

I can't think of an elegant way to do this. A crude way is shown below. To try it copy the search/replace expressions into the appropriate rows/columns (but don't copy the enclosing single quotes).

Row: 1
Search: '(.*)(\(.*?)_(.*\))(.*)'
Replace: '\1\2xxx\3\4'
Row: 2
Search: '(.*)(\(.*?)_(.*\))(.*)'
Replace: '\1\2xxx\3\4'
Row: 3
Search: '_'
Replace: ' '
Row: 4
Search: 'xxx'
Replace: '_'

The first row replaces the first '_' found within a set of parentheses with the characters xxx. The second row is identical and is used in case there is a second occurence. You can add repeat the row as many times as required.
WHen the third row executes, it is assumed that the only '_' characters left are outside any enclosing parentheses and therefore changes each '_ to a blank. The fourth row changes back the xxx's to '_'.
You can replace the xxx with another string if you want in case xxx can occur natually in the filenames.

Hope this helps.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eidolen



Joined: 15 Apr 2008
Posts: 11

PostPosted: Mon Sep 07, 2009 11:35 am    Post subject: Reply with quote

Thanks Peter,
I ended up coming up with a similar solution but thought I was missing something obvious to do it one go. At least I don't feel so bad about myself now. =D

Hope you have a great holiday,
Cheers
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own Video Sharing Site

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com