Re: Regular expression to match surrounding parenthesis

From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 07/07/04


Date: Wed, 07 Jul 2004 20:47:02 +0200

Bob wrote:
> I am trying to create a regular expression to verify that user
> entered data is surrounded by the same number of open and closed
> parenthesis.
>
> For example: if 'a' was the expression I was trying to match then
> a, (a), ((a)), (((a)))... (((((((a))))))) would all be valid.

What about nesting?

The CPAN module Text::Balanced might be helpful.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


Relevant Pages

  • Re: [expect] using the previous output as input
    ... > of an expect send clause? ... Of course you have to verify this regular expression whether it matches your ... expect sets during "expecting". ...
    (comp.lang.tcl)
  • How can I write a Regex to do this?
    ... I want to write a regular expression, I hear that using this can find ... Verify part numbers hat are in the following format would return true. ... followed by a dash than a five digit number begining with an 8 or 9 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: RegEx
    ... Also O'Reilly book 'Mastering Regular Expression' ... rest = <empty string> ... I need to verify that the string represents a fully path ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regular expression to match surrounding parenthesis
    ... Bob wrote on MMMCMLXIII September MCMXCIII in ... I am trying to create a regular expression to verify that user entered ...
    (comp.lang.perl.misc)
  • Re: Regular expression to match surrounding parenthesis
    ... `` bob_nf@hotmail.com wrote: ... ``> I am trying to create a regular expression to verify that user entered ... ``> data is surrounded by the same number of open and closed parenthesis. ... The algorithm may be 'simpler' by some standard, ...
    (comp.lang.perl.misc)