Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

URL's in regular expressions



Thanks for reading this: I need help to fine-tune a regular expression
I'm using to add anchor tags to URL's. The URL's are from (plain text)
emails, and I add anchor tags before publishing them on the web.

Here's the problem: this regexp works OK unless the URL is followed by
a period, i.e., if it's at the end of a sentence. I'd like to tune it
so that it does _NOT_ include the trailing period in the anchor tag.

So, http://billhorne.com works fine, and produces <a
href="http://billhorne.com";>http://billhorne.com</a>. However, if the
URL is at the end of a line, e.g., "... visit http://billhorne.com.";,
then http://billhorne.com. becomes 
<a href="http://billhorne.com.";>http://billhorne.com.</a>.

All suggestions welcome. TIA.

sed '/&lt;http:/!s/\(http:\/\/[-A-Za-z0-9:#@%/;$()~_?+=\\\.&]*\)/<a href="\1">\1<\/a>/g' c3 >c4a


-- 
Bill Horne







BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org