W3C home > Mailing lists > Public > www-style@w3.org > March 1998

Re: Suggested COMPROMISE for regexps (was: OPINIONS WANTED: regexps in CSS?)

From: Steven Pemberton <Steven.Pemberton@cwi.nl>
Date: Fri, 13 Mar 1998 14:55:34 +0100 (MET)
To: www-style@w3.org
Message-ID: <13577.15014.679580.248008@schoener.cwi.nl>
 > *no opinion*
 > Stephanos Piperoglou
 > Steven Pemberton

This isn't a voting forum, and we weren't asked for a vote either, but 
I just want to make it clear that just because I didn't say in a mail 
whether or not I thought REs should be in CSS doesn't mean I don't
have an opinion!

For the record I don't think REs are a good solution for CSS. Just
look at this thread: at least two of the RE experts got the wrong
answer to to Bert's original question (and I was one of them).

And now, to lighten your day, here are the regexps I used to match email
addresses and URLs in order to make them clickable. The files in this 
case were 300 submissions to a conference, and the regexps for the
mail addresses were heuristically built to match what was in those
files.

Enjoy!

 sed '/mailto:/!s/[a-zA-Z0-9][a-zA-Z0-9+\\._\\/\\-]*@[a-zA-Z0-9\\._\\-]*[a-zA-Z0-9]/<A HREF="mailto:&">&<\/A>/g
      s/\([^"]\)\(http:\/\/[a-zA-Z0-9_\\.\/~\#\\-]*[a-zA-Z0-9_\/]\)/\1<A HREF="\2">\2<\/A>/g
      s/^http:\/\/[a-zA-Z0-9_\\.\/~\#\\-]*[a-zA-Z0-9_\/]/<A HREF="&">&<\/A>/
      s/\([^"]\)\(ftp:\/\/[a-zA-Z0-9_\\.\/~\\-]*[a-zA-Z0-9_\/]\)/\1<A HREF="\2">\2<\/A>/g
      s/^ftp:\/\/[a-zA-Z0-9_\\.\/~\\-]*[a-zA-Z0-9_\/]/<A HREF="&">&<\/A>/g
      s/{\([^|,;@}]*\)\([|,;][^}]*}[ ]*@[ ]*\)\([a-zA-Z0-9_\\.\\-]*[a-zA-Z0-9]\)/{<A HREF="mailto:\1@\3">\1<\/A>\2\3/
      s/\({[^}]*[,;|][ ]*\)\([^<,;|@}]*\)}[ ]*@[ ]*\([a-zA-Z0-9_\\.\\-]*[a-zA-Z0-9]\)/\1<A HREF="mailto:\2@\3">\2<\/A>}@\3/
      :try
      s/\([|,;][ ]*\)\([a-zA-Z0-9_\\.\\-+]*\)\([,;|][ ]*[^}]*}[ ]*@[ ]*\)\([a-zA-Z0-9_\\.\\-]*[a-zA-Z0-9]\)/\1<A HREF="mailto:\2@\4">\2<\/A>\3\4/g
      t try'

Steven Pemberton
Received on Friday, 13 March 1998 08:55:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:54 GMT