in reply to Construct a REGEX by selected substitution

This will help you. I always use this technique.
my $str = '<a code=TXT> abc TXT </a> <text code=TXT> efg TXT </text> < +input s=TXT> hig TXT</input>'; print "Before: ",$str,"\n#########\n"; $str =~ s{(>)(.*?)(<)} { my ($tag_ends, $mydata, $tag_starts) = ($1,$2,$3); $mydata =~ s/TXT/FOO/gs; "$tag_ends$mydata$tag_starts" }exgs; print "After: ",$str,"\n#########\n";
Let me know if you need any more help.

Replies are listed 'Best First'.
Re^2: Construct a REGEX by selected substitution
by pysome (Scribe) on Sep 30, 2007 at 02:11 UTC
    Thank you very much. Although it is verbose by modifier :/ex.