Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Regular expression "replace string interpolation" problem

by JEB (Novice)
on Oct 24, 2010 at 16:11 UTC ( #867054=note: print w/ replies, xml ) Need Help??


in reply to Regular expression "replace string interpolation" problem

What about this replace text, which attempts to lower case the protocol and hostname in a URL string, but leave the path (and anything else) as is:

my $url = 'http://www.FOo.COm/wibbLE'; my $search = '^([^:]+://[^/]+)/?(.*)?$'; my $replace = '\L$1\E/$2'; printf "%s\n", $url if ($url =~ s!$search!$replace!);

Anyone got a way of not resorting to "/e" or "/ee" or eval to make this work? For me the $replace is coming from a database, and I don't trust the code so I dont want it doing an "unlink /" or similar! :)


Comment on Re: Regular expression "replace string interpolation" problem
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2015-07-07 11:33 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 (88 votes), past polls