Google Answers Logo
View Question
 
Q: A regular expression to validate regular expressions? ( No Answer,   1 Comment )
Question  
Subject: A regular expression to validate regular expressions?
Category: Computers > Programming
Asked by: ksclarke-ga
List Price: $10.00
Posted: 02 Jun 2003 10:25 PDT
Expires: 02 Jul 2003 10:25 PDT
Question ID: 212007
I need a regular expression to validate regular expressions.  Just
compiling it as a regex in Java and seeing if an
InvalidPatternException is thrown is not acceptable.  It must be a
regex string that matches or doesn't match a string that is a regular
expression

Thanks!

Request for Question Clarification by endo-ga on 02 Jun 2003 10:44 PDT
What language do you want this in?
Would Haskell be acceptable?
What operators do you want to use?
Thanks.
endo

Clarification of Question by ksclarke-ga on 02 Jun 2003 11:45 PDT
I do not want code in any particular language but a generic regex
pattern that could be fed to any Perl style regex engine (implemented
in Perl or Java or anything else) that would allow the engine to
validate a supplied regex string (that could be any variation of a
regular expression)...

Basically all standard operators: Match-self Operator,
Match-any-character Operators, Concatenation Operators, Juxtaposition,
Repetition Operators, Alternation Operators, List Operators, Grouping
Operators, Back-reference Operators, Anchoring Operators...

  I'm hoping someone knows where such a thing already exists (it must,
but I haven't been able to find it) since I think actually writing it
is probably more than a ten dollar answer :-)

Thanks
Answer  
There is no answer at this time.

Comments  
Subject: Re: A regular expression to validate regular expressions?
From: maniac-ga on 02 Jun 2003 17:42 PDT
 
Hello Ksclarke,

I believe it is impossible to produce a "regular expression" for
regular expressions. The problem I see is basically the presence /
absence of nested (), [], and similar constructs. You can certainly
produce a pattern that addresses a "relatively small" set of
combinations, but will fail with anything more complicated. There are
some sites that describe the regular expression problem in numeric
terms such as "NP Complete" and that some patterns require Exponential
processing (not polynomial). I can provide references for them if you
are interested.

  --Maniac

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy