Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Construct a REGEX by selected substitution

by sanPerl (Friar)
on Sep 29, 2007 at 17:21 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-24 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found