
Debuggex: visual regex tester – now with PCRE - tsergiu
http://www.debuggex.com/?flavor=pcre
======
TallboyOne
If you like tools like this one, here's some more. There's a lot of 'visually
see' the regex type tools.

As one who always forgets regex after 3 months of not using it, I find them
helpful :)

[http://pineapple.io/resources/tagged/regular-
expressions?sor...](http://pineapple.io/resources/tagged/regular-
expressions?sort=all_time)

I particularly find this one fascinating, even though I don't fully grasp:
[http://jkff.info/articles/ire/](http://jkff.info/articles/ire/)

------
bane
I wish there was a decent set of tools for using regexes as list generators.
I've seen a few tools and libraries, but they make weird assumptions and never
quite do what I want.

Here's what I'd like:

\- Infinite repetition operators are automatically rewritten as constrained
repetition operators based on some global parameters e.g. * = {0,2}, + =
{1,2}, {n,} = {n,n+3} or some such

\- Character classes can be rewritten as well so . can be kept as "just
printable ASCII codes" instead of veering off into all sorts of unicode bits

\- Exhaustive list generation, generate every possible match using the rules
above. Too many tools seem to go about some sort of random walk against the
FSM and you never know what you're going to end up with

\- Decent coverage of operators. Too many have weird limits like no {,}
operator or no [] character classes.

Getting exhaustive lists like this can be a better way of showing what a regex
will match than trying a bunch of examples. A Perl and/or Python library would
be extra awesome.

~~~
tsergiu
Can you give me a use case for this? It is not very hard to do, given that
random matches are already being generated, but I'm skeptical of its
usefulness.

~~~
bane
Use-cases:

1) regex search against an indexed database: use a regex to generate a search
list, search a well indexed database with this list instead of linearly
scanning data in the database with the regexes. AFAIK there's no way to index
in a way that is regex friendly, only wildcard friendly...so most database
systems that offer regex search just do a more traditional regex match against
the contents of the table elements. In most cases, even searching tens of
thousands of terms will be faster than the typical regex alternative.

2) education - you might use the generated lists while learning regexes to
verify that you've accounted for various edge cases

3) data verification - you're using a regex to verify data, something is
slipping through, see if it exists in the edge of generated matches
(surprisingly common problem)

4) software testing & quality assurance. Define the possible inputs to a
method via regex and generate all possible inputs instead of just testing at
boundary conditions etc.

5) security/penetration testing, like #4 but to test cryptographic systems,
passwords etc.

there's tons more...

Generating random members isn't sufficient as the runtime can grow
extraordinarily long as you keep generating hoping you get all possible
members, and you may not be certain when you can halt.

Some tools like tempting, like Microsoft Research's Rex
[http://research.microsoft.com/en-
us/projects/rex/](http://research.microsoft.com/en-us/projects/rex/)

but the member list it generates is incomplete for example:
^(rich|richard|dick)( j\\.)? th?om{1,2}[ae]s{1,2}[eo]n$

generates: "rich\sj.\sthommesson" "richard\sthomasen" "dick\stomasen"
"rich\stommeson" "dick\sj.\stommassen" "dick\sj.\sthomessen" "dick\sthomessen"
"rich\sthommeson" "richard\stommasen" "rich\sthomesen"

which misses a whole host of other matches

~~~
tsergiu
Thanks for the feedback! I'll take this into account for future development
plans.

------
dfc
While not a visual tool I highly recommend txt2regex[1]. It is a regex wizard
that helps you build regexs for a number of different environments. It
supports:

    
    
      a) -awk                                m) -mysql
      b) -ed                                 n) -ooo
      c) -egrep                              o) +perl
      d) -emacs                              p) +php
      e) -expect                             q) +postgres
      f) -find                               r) -procmail
      g) -gawk                               s) +python
      h) -grep                               t) +sed
      i) -javascript                         u) -tcl
      j) -lex                                v) -vbscript
      k) -lisp                               w) -vi
      l) -mawk                               x) +vim
    
    

[1]
[http://aurelio.net/projects/txt2regex/](http://aurelio.net/projects/txt2regex/)

------
awwaiid
Also check perl's Regexp::Debugger module (which provides an rxrx command) for
a nice console regex debugger.

------
bliker
Maybe somebody can give me of workflow tip:

I have collection of regexes, they each have several test cases that they
should/should not match. Is there any good app that can do something like:

1\. Manage Regexes

2\. Create, add and modify test cases

3\. Run test cases on change

4\. Set different implementation (Javascript do not have lookbehind)

(5.) Sharable Urls

I will be grateful for any tips.

~~~
tsergiu
Debuggex already covers 4 and 5.

Real-time unit testing is actually the next major feature planned (I expect
the release to be in about 4-6 weeks). That will cover 2 and 3.

1 will be improved in the _very_ near future.

~~~
bliker
That sounds promising :) I also managed to find some mockup I got when I was
thinking about working on something like that

[http://jsbin.com/axojax/2](http://jsbin.com/axojax/2)

some UI tips:

1\. Make the font bigger for inputs + add padding for input elements.

2\. Make difference between _ and space and other escaped characters more
noticeable.

Great work!

~~~
tsergiu
Thanks for the feedback! There will be a ui overhaul once all the major
features are done. That will be in a few months.

------
ExpiredLink
When you need wizards and debuggers to formulate a question your grandmother
would understand then your API is clearly broken. Regular expressions are a
failure. A new interface to 'pattern matching' is long overdue. Smart young
people, it's your turn!

~~~
kaoD
Complicated stuff is complicated.

~~~
ExpiredLink
Simple stuff need not be complicated.

------
vito
Took pretty well to this URI regexp from Ruby. Impressive!

[http://www.debuggex.com/r/y47J4d_L02NwJrXq/0](http://www.debuggex.com/r/y47J4d_L02NwJrXq/0)

------
arbus
The RFC822 email address regex :
[http://www.debuggex.com/r/-Izy_lmZmdCAITvQ/0](http://www.debuggex.com/r/-Izy_lmZmdCAITvQ/0)

Very pretty indeed

~~~
vithlani
Wow!

Is there a way to export this as a JPEG|PNG?

~~~
tsergiu
Click "Export to StackOverflow", then you can save the image.

------
kryten
Great work. This is exactly what I want. Thank you so much for putting your
time into making this.

The syntax diagram is wonderful!

------
rohitv
I saw your presentation at the Velocity Pitch Night, I loved it then and
loving it now. Keep up the good work! :)

~~~
tsergiu
Thanks! I'm very flattered that you created an account to leave a comment :)

------
tagawa
My favourite is [http://www.regexper.com/](http://www.regexper.com/) which
seems to be simpler and more visually appealing (no affiliation).

------
jfe
there's a program called 'grep' that does this, too... >_>

~~~
tsergiu
grep has a very different purpose. Here's just one use case that it's not good
at:

I see a regex in some code that I don't own. What does the regex do?

------
shelf
regexr is another of these - better, arguably

