
Regulex – JavaScript Regular Expression Visualizer - ctchenn
http://jex.im/regulex/
======
felipesabino
I use [https://www.debuggex.com/](https://www.debuggex.com/) for regular
expression debugging and testing.

I find it more useful as it can show how each position of my test string
relates to parts of my regular expression

~~~
state
I wonder if the author knew this existed.

~~~
kremi
Yeah debuggex's output looks slightly better, on top of having a lot more
options. Regulex however is open-source with nicely written javascript:
[https://github.com/JexCheng/regulex](https://github.com/JexCheng/regulex)

Here's a side by side comparison with the regexp I wrote to parse URLs [0]

Debuggex:
[https://www.debuggex.com/r/yPBRv77Rxl0Ji3Pi](https://www.debuggex.com/r/yPBRv77Rxl0Ji3Pi)

Regulex:
[http://jex.im/regulex/#!embed=true&re=^%28https%3F\%3A%29\%2...](http://jex.im/regulex/#!embed=true&re=^%28https%3F\\%3A%29\\%2F\\%2F%28%28\[^%3A\\%2F%3F%23\]*%29%28%3F%3A\\%3A%28\[0-9\]%2B%29%29%3F%29%28\\%2F\[^%3F%23\]*%29%28\\%3F\[^%23\]*|%29%28%23.*|%29%24)

[0]
[http://stackoverflow.com/a/21553982/542156](http://stackoverflow.com/a/21553982/542156)

~~~
Alphasite_
On the whole yes, but the minor tweak of expanding shirt hand into a full
statement really makes it easier to follow.

------
JexCheng
Thanks for sharing it here. Actually I didn't intend to publish this tool at
the beginning,because there are some already. This tool emerges from a piece
of extempore code which is a regex parser implemented with DFA only. Then I
give it a GUI,so becomes regulex.

Debuggex and regexper are powerful,I agree,that I also hesitate whether
there's any reason to publish it.

But I'd like to point out some merits of regulex:

\- Regulex is dedicated to ECMAScript RegExp syntax(So I didn't plan to add
PCRE support now)

\- regexper.com can not point out the syntax error index precisely.(Much JS
interpreter can not do that)

\- regexper and debuggex both tolerate OctalEscape.

\- Regulex can detect invalid backref,which is treated as OctalEscape in
Debuggex and regexper.

\- Because of OctalEscape's complexity, Debuggex did not parse `(\1)\1\2`
correctly (
[https://www.debuggex.com/r/_U1r_NxTvLan7h9R](https://www.debuggex.com/r/_U1r_NxTvLan7h9R)
),also regexper.And /^\1(a)$/ will match "a",not "aa".So I treat it as an
error.

So at least it can be used to find javascript regex syntax error. ;)

~~~
tsergiu
One of the creators of debuggex here.

For javascript, debuggex conforms to the regular expression implementation in
google chrome (which is mostly the same as all other browsers).

Specifically, a \n in your regex where group n doesn't exist is actually
interpreted as the octal \00n.

If I recall correctly, \1(a) should match just "a" because all groups start
out as being empty.

Parsing regular expressions is indeed complex, and we've got a massive suite
of tests to make sure our engine works correctly (with respect to the chrome
implementation, since that's what most people are using js regexes for).

~~~
JexCheng
Thank you for the great works of debuggex, I like it.

My little tool didn't intend to act like a extreme powerful and
multifunctional tool which debuggex is. I know debuggex need to conform
existing regex engines,so it will be more useful and can be widely applied.
But what my tool intended is another side,trying to point out errors
strictly.Such as /\1(a)/ or /(\1)/ doesn't make sense, so I think the ability
to report errors like this will be useful.Although js interpreter's regex
engine still supports octal today,but I remove it radically(see the project
README).Maybe this little feature is useful for someone. ;)

------
xtacy
Pretty impressive. I took a complicated regex that accepts valid email
addresses and the output result looks quite neat:

[http://jex.im/regulex/#!embed=true&re=(%3F%3A%5Ba-z0-9!%23%2...](http://jex.im/regulex/#!embed=true&re=\(%3F%3A%5Ba-z0-9!%23%24%25%26'*%2B%2F%3D%3F%5E_%60%7B%7C%7D~-%5D%2B\(%3F%3A%5C.%5Ba-z0-9!%23%24%25%26'*%2B%2F%3D%3F%5E_%60%7B%7C%7D~-%5D%2B\)*%20%20%20%7C%20%20%22\(%3F%3A%5B%5Cx01-%5Cx08%5Cx0b%5Cx0c%5Cx0e-%5Cx1f%5Cx21%5Cx23-%5Cx5b%5Cx5d-%5Cx7f%5D%20%20%20%20%20%20%20%7C%20%20%5C%5C%5B%5Cx01-%5Cx09%5Cx0b%5Cx0c%5Cx0e-%5Cx7f%5D\)*%22\)%20%40%20\(%3F%3A\(%3F%3A%5Ba-z0-9%5D\(%3F%3A%5Ba-z0-9-%5D*%5Ba-z0-9%5D\)%3F%5C.\)%2B%5Ba-z0-9%5D\(%3F%3A%5Ba-z0-9-%5D*%5Ba-z0-9%5D\)%3F%20%20%20%7C%20%20%5C%5B\(%3F%3A\(%3F%3A25%5B0-5%5D%7C2%5B0-4%5D%5B0-9%5D%7C%5B01%5D%3F%5B0-9%5D%5B0-9%5D%3F\)%5C.\)%7B3%7D%20%20%20%20%20%20%20%20\(%3F%3A25%5B0-5%5D%7C2%5B0-4%5D%5B0-9%5D%7C%5B01%5D%3F%5B0-9%5D%5B0-9%5D%3F%7C%5Ba-z0-9-%5D*%5Ba-z0-9%5D%3A%20%20%20%20%20%20%20%20%20%20%20\(%3F%3A%5B%5Cx01-%5Cx08%5Cx0b%5Cx0c%5Cx0e-%5Cx1f%5Cx21-%5Cx5a%5Cx53-%5Cx7f%5D%20%20%20%20%20%20%20%20%20%20%20%7C%20%20%5C%5C%5B%5Cx01-%5Cx09%5Cx0b%5Cx0c%5Cx0e-%5Cx7f%5D\)%2B\)%20%20%20%20%20%20%5C%5D))

------
mansilladev
These never get old for me. I don't think I've ever used one when I needed it
most, because it slips my mind as I power through building a complex regex..
but damn it, not the next time round.

------
Abstain
This is great but I prefer - [http://www.regexr.com/](http://www.regexr.com/)

~~~
XorNot
+1 regexr is my goto tool for regex's.

------
guard-of-terra
Everybody seems to write a regex visualizer.

It's neat, simple enough to actually finish it and rewarding enough because
people like regexes.

The first one I was exposed to is probably KRegexEditor.

But I think it's non-news otherwise.

------
santialbo
It looks very cool.

I think that on nullable quantifiers (? and (how the fuck do I type a star on
the comments)) it misses the optional branch (check
[http://www.regexper.com/#ab*c](http://www.regexper.com/#ab*c) vs
[http://jex.im/regulex/#!embed=false&re=ab*c](http://jex.im/regulex/#!embed=false&re=ab*c)
to see what I mean).

------
sublimino
Does well on the UK Government Postcode Regex from
[http://stackoverflow.com/a/164994/114770](http://stackoverflow.com/a/164994/114770):

    
    
      http://jex.im/regulex/#!embed=false&re=(GIR%200AA)%7C(((%5BA-Z-%5BQVX%5D%5D%5B0-9%5D%5B0-9%5D%3F)%7C((%5BA-Z-%5BQVX%5D%5D%5BA-Z-%5BIJZ%5D%5D%5B0-9%5D%5B0-9%5D%3F)%7C((%5BA-Z-%5BQVX%5D%5D%5B0-9%5D%5BA-HJKSTUW%5D)%7C(%5BA-Z-%5BQVX%5D%5D%5BA-Z-%5BIJZ%5D%5D%5B0-9%5D%5BABEHMNPRVWXY%5D))))%20%5B0-9%5D%5BA-Z-%5BCIKMOV%5D%5D%7B2%7D)
    

edit: the link won't embed here nicely

------
dandrino
Really interesting visualizing an expression for recognizing multiples of 3
(in base 10)

[http://jex.im/regulex/#!embed=false&re=%5E(%5B0369%5D%7C%5B1...](http://jex.im/regulex/#!embed=false&re=%5E\(%5B0369%5D%7C%5B147%5D%5B0369%5D*\(%5B147%5D%5B0369%5D*%5B258%5D%5B0369%5D*\)*\(%5B147%5D%5B0369%5D*%5B147%5D%7C%5B258%5D\)%7C%5B258%5D%5B0369%5D*\(%5B258%5D%5B0369%5D*%5B147%5D%5B0369%5D*\)*\(%5B258%5D%5B0369%5D*%5B258%5D%7C%5B147%5D\)\)%2B%24)

------
mquandalle
Looks similiar to [http://www.regexper.com](http://www.regexper.com) but
working fully on the client.

------
crucialfelix
[https://atom.io/packages/regex-railroad-
diagram](https://atom.io/packages/regex-railroad-diagram) The main diagram and
regex packages are separate node packages, by the same author.

It's nice because it automatically detects when your cursor is in a regex and
opens a bottom panel. works for js and Python.

------
jdnier
My favorite large regex for testing sites like this (Regulex link was very
long, so here's a tinyurl):

[http://tinyurl.com/ovmvphg](http://tinyurl.com/ovmvphg)

Original paper:
[http://www.cs.sfu.ca/~cameron/REX.html](http://www.cs.sfu.ca/~cameron/REX.html)

------
thomasfl
Kudos to Cheng for putting this nice regexp visualization tool out there.
Regexp editors are indispensable for complex regexp'es. I still come back to
this minimalistic regexp editor [http://rubular.com](http://rubular.com) when
doing regexp in ruby.

------
silentrob
Wow, there is no shortage of great tools. I really like rubular.com - even
though it is for Ruby I use it for JavaScript too. Being able to generate a
url and save it in my code comments is extremely valuable when I come back to
the code.

------
othmanaba
Very nice. but it should visualize repetition instead of printing "Repeat 1 or
more times". e.g. for "a+" it should be "a -> a*"

------
amenghra
[http://regexp.quaxio.com/](http://regexp.quaxio.com/)

------
NKCSS
To bad it doesn't work on my phone :(

------
oburb
can't do negations, e.g. ^[ ]

------
oburb
doesn't do negations

------
gosukiwi
Dat comic sans though :P

