Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regex to replace a particular part of content

by reneeb (Chaplain)
on Jun 22, 2006 at 11:25 UTC ( #556890=note: print w/ replies, xml ) Need Help??


in reply to Regex to replace a particular part of content

my $bla = qq+The quick brown fox jumps over the lazy dog. The quick br +own fox jumps over the lazy dog. The quick brown fox jumps over the l +azy dog. The quick brown fox jumps over the lazy dog. The quick brown + fox jumps over the lazy dog. The quick brown fox jumps over the lazy + dog. <list>The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</list> The quick brown fox jumps over the lazy dog. The quick brown fox jumps + over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps ov +er the lazy dog. The quick brown fox jumps over the lazy dog.+; $bla =~ s~(<list>)(.*?)(</list>)~$1.subst($2).$3~es; print $bla; sub subst{ my ($string) = @_; print $string; my $res = ""; for(split(/\n/,$string)){ $res .= '<item>'.$_.'</item>'."\n"; } return $res; }


Comment on Re: Regex to replace a particular part of content
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2015-07-07 23:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls