|
|
| laziness, impatience, and hubris | |
| 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?? |
|
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
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||