Peters Flexible RenAmiNg Kit (PFrank) Forum Index Peters Flexible RenAmiNg Kit (PFrank)
Support and Discussion Site for the PFrank File/Folder Renaming Tool (http://www3.telus.net/pfrank)
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Putting 0 between two replacement group numbers

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



Joined: 03 Oct 2007
Posts: 3

PostPosted: Wed Oct 03, 2007 4:47 am    Post subject: Putting 0 between two replacement group numbers Reply with quote

I've run into a minor problem where I have two captured groups to use in a replacement, and I wanted to place a zero between them.
e.g the replacement should be a zero between \1 and \2 which ends up \10\2. I think you can see the problem - PFrank interprets this as group 10 followed by group 2 (although there are only 2 captured groups), and complains and stops. I tried substituting hex \x30 for the space - i.e. \1\x30\2, and also tried quoting the zero, but no luck. I worked around it by first replacing with a space followed by the zero thusly: \1 0\2 and then did a second replace of the space with nothing. I don't think this is unique to PFrank, just a fluky combination in a regex. Am I overlooking something obvious - Is there any way to define the zero in this position so it would be a single replace?

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


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Wed Oct 03, 2007 5:28 am    Post subject: Reply with quote

You need to use the non-ambiguous notation:

\g<1>0\2

or

\g<1>0\g<2>

The \g notation is used for cases like the one you just described to remove any ambiguity in back references.

Great question!

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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