Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: changing only the first two matches of a regex

by knight (Friar)
on Mar 20, 2001 at 19:48 UTC ( [id://65711]=note: print w/replies, xml ) Need Help??


in reply to changing only the first two matches of a regex

If the problem is really that you only want to do this to the first two fields, the previous replies cover that.

But if you mentioned "first two matches" in reference to the specific sample data you show, and the underlying general problem is that you want to remove \d_ from the beginning of any and all /-separated fields in a string, then try:
s#(^|/)\d_#$1#g;
The (^|/) alternation matches at the beginning of the line or after your field separator, which avoids inadvertently matching and remove \d_ from the middle of a field.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://65711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-29 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found