Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: replacing variable in regex - probs with special chars?

by integral (Hermit)
on Jan 31, 2003 at 07:43 UTC ( [id://231538]=note: print w/replies, xml ) Need Help??


in reply to replacing variable in regex - probs with special chars?

Surely the code can be simplified by using a s///g at the top level instead of looping?
$source =~ s/(\[link title:(.*?)\](.*?)\[\/link])/<a href='$3'>$2<\/a> +/gi;
The obvious limitation over the original solution is that it doesn't allow one to loop, but perhaps this would work?
while ($source =~ s/\G(\[link title:(.*?)\](.*?)\[\/link])/<a href='$3 +'>$2<\/a>/i) { print "complete: $1\ntitle: $2\nurl: $3\n"; }

--
integral, resident of freenode's #perl

Log In?
Username:
Password:

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

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

    No recent polls found