Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I’m maintaining a program that (among other things) reads a users input and, if necessary, inserts the appropriate <a href= > tag. Currently it uses the following regex:
s/((http|ftp|news):\/\/\S*)/<a href=”$1\””>$1<\/a>/g; The main problem is that this regex will place tags around all urls. This creates problems if the user has already hand coded the tags in their input, such as <a href = http://www.perlmonks.org>Click here</a> Can any Monks suggest a regular expression that will insert href tags around naked urls, but leave urls within tags alone? In reply to Adding href where needed. by electronicMacks
|
|