Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: What is missing from the beginning of this string? (direct)

by tye (Sage)
on Oct 08, 2010 at 05:12 UTC ( [id://864145]=note: print w/replies, xml ) Need Help??


in reply to What is missing from the beginning of this string?

#!/usr/bin/perl -p s-^(((((((h?t)?)t)?p)?:)?/)?/)?(?=\w+\.)-http://-; __END__ http://www.perlmonks.org/ ttp://www.perlmonks.org/ tp://www.perlmonks.org/ p://www.perlmonks.org/ ://www.perlmonks.org/ //www.perlmonks.org/ /www.perlmonks.org/ www.perlmonks.org/

produces

http://www.perlmonks.org/ http://www.perlmonks.org/ http://www.perlmonks.org/ http://www.perlmonks.org/ http://www.perlmonks.org/ http://www.perlmonks.org/ http://www.perlmonks.org/ http://www.perlmonks.org/

(update:) Replace \. with [./] if you want to support intranet URLs like http://cvs/. Supporting alternate-port intranet URLs like http://wiki:8080/ with just [./:] would cause ftp://... to become http://ftp://... but you could consider (?=\w+([./]|:\d)).

- tye        

Log In?
Username:
Password:

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

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

    No recent polls found