Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: replace url in text with html link

by Roger (Parson)
on May 24, 2005 at 15:40 UTC ( [id://460042]=note: print w/replies, xml ) Need Help??


in reply to replace url in text with html link

A very simple HTML link replacement regex that ignores the last period (.):

my $html = do { local $/; <DATA> }; $html =~ s!(https*:\S*?)(\.*?\s)!<a href="$1">$1</a>$2!gm; print $html; __DATA__ Students can activate their UMSIS userids on-line by filling out and s +ubmitting the form at https://umsis.miami.edu/sign-up. ...which can be obtained via the web at http://www.miami.edu/it-forms/ +.


Replies are listed 'Best First'.
Re^2: replace url in text with html link
by davidrw (Prior) on May 24, 2005 at 16:27 UTC
    This might be nitpicky, but perhaps (hopefully) educational for the OP. Caught my eye because we actually had almost identical responses... (mine is here)
    • I had http? and you had https* -- yours would match httpssss://blah.com since the * is zero more instead of ? being 0 or 1
    • I have ://\S+? and you have :\S*? -- yours would match http:. or http: or http:/blah or http:blah.com
    • I have (\.?\s) and you have (\.*?\s) -- I think yours is better here, but i'm sure how the two non-greedy (one for \S and one for \.) work together in the case of http://blah.com...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-29 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found