
Visual Support for Working with Regular Expressions - beckf
http://softvis.wordpress.com/2014/12/22/visual-support-for-working-with-regular-expressions/
======
viggity
I think one reason why most people have a hard time reading regex is because
they don't use any indentation or linebreaks.

Honestly, if a buddy came to you and asked you to help him debug a javascript
method and all 15 statements were on the same line, would you offer to help
him, or tell him to fix his shit first so you can read it?

What if it was all on one line and his variable names were all "v1", "v2",
etc. Would you help him then? fuck no. And yet, this is standard operating
procedure with regex, except you don't even get "v1", "v2" because nothing is
labeled at all. v1/v2/... would be an improvement!

This is how most people write a simple date regex:

\d{1,2}/\d{1,2}/(\d{4}|\d{2})

And mind you, this is a very simple scenario. Here is how you would write it
if you treated it like actual code:

(?<month>\d{1,2})

/

(?<day>\d{1,2})

/

(?<year>\d{4}|\d{2})

First off, you can know what my intent is when I'm capturing each group. Maybe
this code gets used by a european where the month and day switch places. They
can figure out how to fix it in like two seconds. Secondly, the forward
slashes are not lost in a sea of characters anymore because we use whitespace
like a civilized developer, not a regex savage.

I linked it in another comment, but I've got a free regex tool that I wrote
www.regexpixie.com. my email is in my profile if anyone has any
questions/comments.

~~~
darrencauthon
That's a neat tool you mention... is it available on Linux or OSX???? :P

~~~
viggity
I should have figured you'd give me grief, darren. It has Linux and OSX
support if you're willing to run windows in a VM ;)

------
james-skemp
I was expecting something like what
[https://www.debuggex.com](https://www.debuggex.com) offers when they said
visual support. This seems to simply be highlighting like most other tools do.

~~~
beckf
Further below in the post, Debuggex and similar tools are discussed as well.

Regarding the visuals, RegViz can be considered as something between Debuggex
and traditional plain-text tools.

------
1971genocide
If your regular expression gets too complicated you should look into using
parsers like antler,bison,etc. I was scared of learning about parsers
initially since people consider it to be old technology and is usually in the
domain of compiler designers and such, but they are really really cool.

------
viggity
I don't really promote this at all, but I wrote a free regex tool that wasn't
listed.

[http://www.regexpixie.com/](http://www.regexpixie.com/)

Key Features:

* Real Time Highlighting

* Solid Support for Named Groups

* Easily extract just the match or replacement text to clipboard

* write replacement logic with C#

It is free but only works on windows (built on .net).

------
anton_gogolev
ReSharper introduced Regex support in v9:
[http://blog.jetbrains.com/dotnet/2014/10/27/regular-
expressi...](http://blog.jetbrains.com/dotnet/2014/10/27/regular-expression-
support-in-resharper-9/)

------
cones688
Do any of these allow to run offline? i.e local

Edit: Looks like Regexr can be run locally with node
[https://github.com/gskinner/regexr/](https://github.com/gskinner/regexr/)

------
tincholio
Or you could just use Emacs :)

[https://github.com/benma/visual-regexp.el](https://github.com/benma/visual-
regexp.el)

