Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 chanting in the Monastery: (3)
As of 2014-07-10 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (198 votes), past polls