Evaluate sample data against the regex
Opened this issue · 5 comments
It would be really useful to be able to test out the regex on sample data as well. E.g., for a regex of "\d+", perhaps I might throw the following sample data at it:
"a"
""
"0"
"235"
"aslfj235"
A really cool thing to do with this would be to highlight the path through the state machine that is taken when evaluating a piece of sample data.
I don't expect this feature will be added in the near future, but I'm going to keep it around since it does sound like a good idea.
At this point, the expression is not being compiled into a state machine, it is merely being parsed enough to render the image. I haven't done any research into generating the state machine, or the difficulties that may be encountered with tracing the path through that machine, but from past reading I understand that it is not a trivial problem.
I will keep this in mind though.
+1 for being able to test out the regex.
One simplistic way to implement this is to run client-side JS that executes the regex against a given string, rather than processing it via the state machine representation.
There are a few other regex demo sites on the web, and I think they just do the above. Might as well eat their lunch and win their users by gaining their features!!
@aldeka , curious if you'd be interested in hacking on this sometime.
I'm intending to go down that route initially for http://regexplained.co.uk but it does have the downside of not being able to see the path taken through the railroad diagram.