Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using backreferences within a pattern using eregi_replace

2 views
Skip to first unread message

Martin Lucas-Smith

unread,
Dec 20, 2005, 11:13:51 AM12/20/05
to

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:f...@example.com">f...@example.com</a>
WOULD match and be replaced by f...@example.com

but
<a href="mailto:f...@example.com">b...@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

unread,
Dec 20, 2005, 2:31:29 PM12/20/05
to
Martin Lucas-Smith wrote:

> 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'

Backreferences are obsolete in POSIX 1003.2. PCREs support them.

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

--
Jock

0 new messages