regexp for bracket expressions

Hi all!

I am using regular expressions quite a lot.
But somthing I don't know, so far, is if there exists an
regexp matching anything which has equally many opening and closing
brackets, e.g.

(.(..)..(...(...))..)

Any idea

Thank You!
rembremading [ Mi, 19 September 2007 12:02 ] [ ID #1824573 ]

Re: regexp for bracket expressions

rembremading schrieb:
> Hi all!
>
> I am using regular expressions quite a lot.
> But somthing I don't know, so far, is if there exists an
> regexp matching anything which has equally many opening and closing
> brackets, e.g.
>
> (.(..)..(...(...))..)
>
> Any idea
>
> Thank You!


No, not in theory.
papahuhn [ Mi, 19 September 2007 12:51 ] [ ID #1824574 ]

Re: regexp for bracket expressions

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig7724E1D190CB0F3929F31099
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

This is a german newsgroup, so I'll answer in german.

rembremading wrote:
> I am using regular expressions quite a lot.
> But somthing I don't know, so far, is if there exists an
> regexp matching anything which has equally many opening and closing
> brackets, e.g.
>
> (.(..)..(...(...))..)

Es gibt in perlre ein Beispiel, wie das mit p5 Regexes geht. (Relativ
weit unten, bei (?>...) ). Regulär sind diese Ausdrücke dann nicht me=
hr:


$re =3D qr{
\(
(?:
(?> [^()]+ ) # Non-parens without backtracking=

|
(??{ $re }) # Group with matching parens
)*
\)
}x;

HTH,
Moritz


--
Moritz Lenz
http://perl-6.de/ http://moritz.faui2k3.org/


--------------enig7724E1D190CB0F3929F31099
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG8Q+vAAkekJBI0yIRArnwAJ97U4ly2j9NwkX9121qHgCC86Jg7ACf Qto6
ipdOLp03qe0NUVBi3LODKhA=
=qEIM
-----END PGP SIGNATURE-----

--------------enig7724E1D190CB0F3929F31099--
Moritz Lenz [ Mi, 19 September 2007 14:01 ] [ ID #1824575 ]
Perl » de.comp.lang.perl.misc » regexp for bracket expressions

Vorheriges Thema: B::Lint Merkwürdiger Fehler und Frage
Nächstes Thema: Debuggen von @INC