in reply to can't get $& to remove value in a substitution
Gives output:$content = qq(<textarea class="FolderTxtArea" name="blah"><%=foo::doSo +mething%></textarea>); while ($content =~ m/(<textarea.*textarea>)/sg) { my $match = $&; my $varmatch; print "match: before ..... $match\n"; if( $match =~ m/(<%=.*?%>)/sg){ $varmatch = $1; print "varmatch: $varmatch\n"; pos $match ; #cut var tag $match=~ s/$varmatch//g; print "match: after .... $match\n"; $match=~ s/textarea/testinsert$varmatch/g; print "match: after testinsert .... $match\n"; } }
Are you sure you are looking at the output from your latest run?match: before ..... <textarea class="FolderTxtArea" name="blah"><%=foo +::doSomething%></textarea> varmatch: <%=foo::doSomething%> match: after .... <textarea class="FolderTxtArea" name="blah"></texta +rea> match: after testinsert .... <testinsert<%=foo::doSomething%> class=" +FolderTxtArea" name="blah"></testinsert<%=foo::doSomething%>>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: can't get $& to remove value in a substitution
by zusuki-san (Initiate) on Oct 24, 2002 at 14:17 UTC | |
by roik (Scribe) on Oct 24, 2002 at 14:31 UTC |