Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re3: Open to suggestions on a search and replace..

by Hofmator (Curate)
on Apr 12, 2002 at 11:38 UTC ( #158544=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Open to suggestions on a search and replace..
in thread Open to suggestions on a search and replace..

You can use a positive lookahead assertion to avoid having to reinsert $1. $line =~ s/^(?=R.*\$SUB=)<\*\d+>//;

aehhm, this won't work. The lookahead doesn't move the position in your regex, so you are effectively looking for /^<\*\d+>/ which isn't there. Instead you would need a look behind assertion but they are only available for constant length.

As I understand the file format there are no other digits in angle brackets starting with a star. So why not simply write: s/<\*\d+>//;

Update: As of Rhodium's clarification of the specs, I would now fully recommend IO's solution.

-- Hofmator


Comment on Re3: Open to suggestions on a search and replace..
Select or Download Code
Re: Re3: Open to suggestions on a search and replace..
by Rhodium (Scribe) on Apr 12, 2002 at 13:18 UTC
    Hey Hof,
    As I understand the file format there are no other digits in angle brackets starting with a star.
    That is something I don't want to assume..
    Rhodium

    The <it>seeker</it> of perl wisdom.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (18)
As of 2014-07-14 16:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (268 votes), past polls