develooper Front page | perl.perl5.porters | Postings from March 2003

(?{ }) construct to fail regular expression

Thread Next
From:
jonathan stiles
Date:
March 21, 2003 04:17
Subject:
(?{ }) construct to fail regular expression
Message ID:
20030320031006.285.qmail@web13308.mail.yahoo.com
everybody,

I was wondering if there was a way to fail regular
expressions via (?{...}), ie:

if ($non_matching_parens =~ m"
                      (?{$pcount=1})
                       \(
                            (?:
                                [^()]*|
                                \((?{$pcount++})|
                                \)(?{$pcount--}
                            )*
                        (?{ <need this> ($pcount !=
0)? <fail!> : <succeed>) }$
            "sx)

In other words, what's the mechanism for causing a
regex to automatically fail? what's the mechanism for
causing a regex to leave a loop?

I know I could do this programmatically, but it would
be *much* cleaner to do this in regex since all the
rest of my code is regex based.

jon

(ps: is there any good mechanism for searching history
(of perl5/perl6 newsgroups) hunting for special
characters? I tried typing (?{ into google. Pointless.
Same at the .fi archive site.)


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About