[ILUG] regexp / php question
blf at blf.utvinternet.ie
Wed Aug 17 21:40:59 IST 2005
| Date: Wed, 17 Aug 2005 16:39:08 +0100
| From: Stephen Reilly <leydar at gmail.com>
| On 17/08/05, John P. Looney <valen at tuatha.org> wrote:
| > Ah. I should have pointed out that the name and email can change
| > on each line.
| Perhaps something along the lines of:
| sed "s#'\([a-zA-Z0-9-_.]*\)' <\(\([a-zA-Z0-9-_.]*\)@[a-zA-Z0-9-_]*\.[a-zA-Z0-9-_]*\)>#\<a href='thing?\1'\>\1\<\\a\> \<a href='mailto:\2'\>mail \3\<\\a\>#g" filename
| It will replace:
| send an email to 'Looney' <email at domain.com> and tell him about it.
| send an email to <a href='thing?Looney'>Looney<\a> <a href='mailto:email at domain.com'>mail email<\a> and tell him about it.
obvious minor mistake — assuming John is trying
to generate HTML — it is </a> not <\a>.
not knowing exactly what John's input is like,
I wonder if having such specific REs is a good
idea; e.g., if '\([^']*\)' or similar would
be better for the Looney part? and likewise for
the other bits, which are left as an exercise
for the reader.
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
More information about the ILUG