Hi, would it be possible to match a chunk in a file, and then replace only a portion (a phrase) of it?
For example:
$a = "<start>op3 and op and op2</start>"
I need to do things sequentially:
1. Match <start>.+?</start>
2. Replace "op" contained with "op1"
The end result should look like:
$a = "<start>op3 and op1 and op2 </start>"
I tried $a =~ s/<start>(op)[^0-9]</start>/op1/
I keep replacing the entire <start> block instead only a part of it. Does Perl have something like a contextual replacement or conditional replacement, or maybe nested regular exps?
Thanks guys.
For example:
$a = "<start>op3 and op and op2</start>"
I need to do things sequentially:
1. Match <start>.+?</start>
2. Replace "op" contained with "op1"
The end result should look like:
$a = "<start>op3 and op1 and op2 </start>"
I tried $a =~ s/<start>(op)[^0-9]</start>/op1/
I keep replacing the entire <start> block instead only a part of it. Does Perl have something like a contextual replacement or conditional replacement, or maybe nested regular exps?
Thanks guys.