[pcre-dev] [Bug 1393] the opposite of a reference

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 1393] the opposite of a reference
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1393




--- Comment #2 from Philip Hazel <ph10@???> 2013-10-08 15:24:25 ---
On Tue, 8 Oct 2013, ouadji wrote:

> It would be great if PCRE would have a character to get the "opposite" of a
> Reference. Like the negative character class [^...] ,but for a reference...


A negative character class is easy, as it matches ONE character.

> For exemple : (xyz)(^\1) ... matches with "xyz" and all exept "xyz".


What do you mean by 'all except "xyz"'? Do you mean "match 3 characters,
but not 'xyz'"? Will that match "xxx" or "ayz" or not? Or perhaps match
more (or fewer) than 3 characters?

You can get whatever effect you want by using a lookahead. For example:

(xyz)(?!\1)...

That matches, for example xyzabc, zxyzxyx, and so on.

> I'm a little surprised that it does not exist.


Nothing like you suggest exists in Perl, and as PCRE tries to be
reasonably compatible with Perl, so I'm afraid this is very unlikely to
happen.

Regards,
Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email