Connecting Tech Pros Worldwide Help | Site Map

Using backreferences within a pattern using eregi_replace

Martin Lucas-Smith
Guest
 
Posts: n/a
#1: Dec 20 '05


Is there any way to use backreferences _within_ a _pattern_, as works on
some regexp parsing applications, i.e.

'<a href="mailto:([^@]*)@([^"]*)">\\1@\\2</a>'
=>
'\\1@\\2'

so that
<a href="mailto:foo@example.com">foo@example.com</a>
WOULD match and be replaced by foo@example.com

but
<a href="mailto:foo@example.com">bar@example.com</a>
WOULD NOT match (and thus no replacement take place)

?

I can't seem to get this to work. Any suggestions for an alternative?

Martin
John Dunlop
Guest
 
Posts: n/a
#2: Dec 20 '05

re: Using backreferences within a pattern using eregi_replace


Martin Lucas-Smith wrote:
[color=blue]
> Is there any way to use backreferences _within_ a _pattern_, as works on
> some regexp parsing applications, i.e.
>
> '<a href="mailto:([^@]*)@([^"]*)">\\1@\\2</a>'
> =>
> '\\1@\\2'[/color]

Backreferences are obsolete in POSIX 1003.2. PCREs support them.

http://www.tin.org/bin/man.cgi?section=7&topic=regex

--
Jock
Closed Thread