regexp for bracket expressions

regexp for bracket expressions

am 19.09.2007 12:02:24 von rembremading

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!

Re: regexp for bracket expressions

am 19.09.2007 12:51:57 von papahuhn

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.

Re: regexp for bracket expressions

am 19.09.2007 14:01:43 von Moritz Lenz

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=20
> regexp matching anything which has equally many opening and closing
> brackets, e.g.
>=20
> (.(..)..(...(...))..)

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


--=20
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--