Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Utility to locate errors in regular expressions

Reply
Thread Tools

Utility to locate errors in regular expressions

 
 
Malte Forkel
Guest
Posts: n/a
 
      05-24-2013
Finding out why a regular expression does not match a given string can
very tedious. I would like to write a utility that identifies the
sub-expression causing the non-match. My idea is to use a parser to
create a tree representing the complete regular expression. Then I could
simplify the expression by dropping sub-expressions one by one from
right to left and from bottom to top until the remaining regex matches.
The last sub-expression dropped should be (part of) the problem.

As a first step, I am looking for a parser for Python regular
expressions, or a Python regex grammar to create a parser from.

But may be my idea is flawed? Or a similar (or better) tools already
exists? Any advice will be highly appreciated!

Malte

 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      05-24-2013
In article <(E-Mail Removed)>,
Malte Forkel <(E-Mail Removed)> wrote:

> Finding out why a regular expression does not match a given string can
> very tedious. I would like to write a utility that identifies the
> sub-expression causing the non-match. My idea is to use a parser to
> create a tree representing the complete regular expression. Then I could
> simplify the expression by dropping sub-expressions one by one from
> right to left and from bottom to top until the remaining regex matches.
> The last sub-expression dropped should be (part of) the problem.
>
> As a first step, I am looking for a parser for Python regular
> expressions, or a Python regex grammar to create a parser from.
>
> But may be my idea is flawed? Or a similar (or better) tools already
> exists? Any advice will be highly appreciated!


I think this would be a really cool tool. The debugging process I've
always used is essentially what you describe. I start try progressively
shorter sub-patterns until I get a match, then try to incrementally add
back little bits of the original pattern until it no longer matches.
With luck, the problem will become obvious at that point.

Having a tool which automated this would be really useful.

Of course, most of Python user community are wimps and shy away from big
hairy regexes [ducking and running].
 
Reply With Quote
 
 
 
 
Neil Cerutti
Guest
Posts: n/a
 
      05-24-2013
On 2013-05-24, Roy Smith <(E-Mail Removed)> wrote:
> Of course, most of Python user community are wimps and shy away
> from big hairy regexes [ducking and running].


I prefer the simple, lumbering regular expressions like those in
the original Night of the Regular Expressions. The fast, powerful
ones from programs like the remake of Dawn of the GREP, just
aren't as scary.

--
Neil Cerutti
 
Reply With Quote
 
rusi
Guest
Posts: n/a
 
      05-24-2013
On May 24, 5:58*pm, Malte Forkel <(E-Mail Removed)> wrote:
> Finding out why a regular expression does not match a given string can
> very tedious. I would like to write a utility that identifies the
> sub-expression causing the non-match. My idea is to use a parser to
> create a tree representing the complete regular expression. Then I could
> simplify the expression by dropping sub-expressions one by one from
> right to left and from bottom to top until the remaining regex matches.
> The last sub-expression dropped should be (part of) the problem.
>
> As a first step, I am looking for a parser for Python regular
> expressions, or a Python regex grammar to create a parser from.
>
> But may be my idea is flawed? Or a similar (or better) tools already
> exists? Any advice will be highly appreciated!
>
> Malte




python-specific: http://kodos.sourceforge.net/
Online: http://gskinner.com/RegExr/
emacs-specific: re-builder and regex-tool http://bc.tech.coop/blog/071103.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent help needed! unable to locate syntax errors Atul Dongargaonkar Ruby 2 10-06-2010 08:25 PM
Please help !! I need to locate utility which identifies picture files ? spamharvestor@gmail.com Digital Photography 17 10-01-2005 02:49 AM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM
Custom Regular Expressions in ASP.net Jay Douglas ASP .Net 3 11-03-2003 08:09 PM
Add custom regular expressions to the validation list of available expressions Jay Douglas ASP .Net 0 08-15-2003 10:19 PM



Advertisments