Re: s/A/B/ and s/B/C/ but don't want A -> C (was: FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?)
- From: nolo contendere <simon.chao@xxxxxxx>
- Date: Fri, 28 Dec 2007 11:51:53 -0800 (PST)
On Dec 28, 1:52 pm, Ted Zlatanov <t...@xxxxxxxxxxxx> wrote:
Actually, I've often run into the need for parallel edits like this,
where you want to s/A/B/ and s/B/C but you don't want A to become C.
With complex operations or operations you don't know in advance, proper
ordering becomes impossible. I usually handle it with function calls:
s/[ABC]/replacement(\1)/e or something like that. Is there a better
approach anyone can recommend?
What does the above do? Shouldn't that be:
s/[ABC]/replacement( $1 )/e;
?
And could you please expound on "With complex operations or operations
you don't know in advance..."?
I don't see how you could avoid doing an inadvertent A->C if you did
multiple s/// out of order, unless you provided enough context for the
regex to work correctly.
.
- Follow-Ups:
- References:
- FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?
- From: PerlFAQ Server
- Re: FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?
- From: Ben Morrow
- s/A/B/ and s/B/C/ but don't want A -> C (was: FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?)
- From: Ted Zlatanov
- FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?
- Prev by Date: Re: How Do I Locate a value in a text file and evaluate it and then write out that line based on the value?
- Next by Date: Re: s/A/B/ and s/B/C/ but don't want A -> C (was: FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?)
- Previous by thread: s/A/B/ and s/B/C/ but don't want A -> C (was: FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?)
- Next by thread: Re: s/A/B/ and s/B/C/ but don't want A -> C (was: FAQ 6.4 I put a regular expression into $/ but it didn't work. What's wrong?)
- Index(es):
Relevant Pages
|