Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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.


Comment on Re: Construct a REGEX by selected substitution
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://641708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-04-20 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (486 votes), past polls