[dev] regex gurus listen

Cynic cynic@mail.cz
Sat, 14 Jul 2001 20:16:52 +0200


At 19:14 7/12/2001, Rich Lafferty wrote the following:
-------------------------------------------------------------- 
>On Thu, Jul 12, 2001 at 04:47:05PM +0000, Jan Schneider (janmailing@gmx.de) wrote:
>> Hi regex gurus out there!
>> 
>> To make my vcard/ical-parser rfc2425-compliant I need a regex for a weird case. 
>> 
>> Take this line (remove linebreaks):
>> ATTENDEE;PARTSTAT=DELEGATED;DELEGATED-
>> TO="Mailto:E@example.com":Mailto:C@example.com
>> 
>> It has to be split at the first occuring colon _not_ in quoted
>> string. In this case it has to be split at colon before the 2nd
>> 'Mailto'.
>
>Unless preg_* has adopted Perl's negative lookahead assertions (and
>I'm pretty sure it hasn't), you can't do balanced parens/quotes/etc
>with a regular expression. But it's easy to do the old way -- just
>build a DFA that parses character by character.

PCRE (and so the preg_* family in PHP) has negative/positive
lookahead/lookbehind assertions.




cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
    - Book of Installation chapt 3 sec 7