Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Construct a REGEX by selected substitution

by sanPerl (Friar)
on Sep 29, 2007 at 17:21 UTC ( #641708=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://641708]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2017-06-27 19:37 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (612 votes). Check out past polls.