Regex101
Regex101 copied to clipboard
A custom regex101 flag to specify "treat each newline as a separate test string"
A flag in Regex101.com to specify a bunch of newline-separated test strings to test your regex against.
Unit tests are currently the best solution to this, but would still be nice to see.
bonus points: button for "extract unit tests to newline separated regex101 test string field and enable this flag"
How would this work with match information? There can be multiple matches on each line? Does not seem like the system is designed to handle this.
Is it possible to show an up and down arrow in the match information screen to click on to navigate through each regexes match information? A minor pagination system, basically. This could also help with unit tests.
On 10 Mar 2017 09:23, "Firas Dib" [email protected] wrote:
How would this work with match information? There can be multiple matches on each line? Does not seem like the system is designed to handle this.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/firasdib/Regex101/issues/795#issuecomment-285607219, or mute the thread https://github.com/notifications/unsubscribe-auth/ADfaeGEWiuXzkF-scgLCKaSImX1xsacWks5rkQiQgaJpZM4MSPsp .
Seems very complicated if I'm honest.
A better solution would be to try to integrate it into the unit tests somehow.
TL;DR: Import each line of the 'test string' as an individual unit test.
Here's an idea: a 'test string' is filled with whatever data a user is currently testing against. Switching to unit tests, a small 'import from test string' button is added next to the 'expand all tests/collapse all tests' buttons.
That will prompt the user to accept every imported line as either a 'match' or 'not match'. Every line is imported as a single unit test, which clears the 'test string' area.
If a user wants to have half of their text 'matches' and the other half 'non-matches', we just tell them to run it twice: first, remove everything that should not be a match, do an 'import from test string' on the text that's left there (selecting 'match'), then paste back in the 'non-match' text and run it again (selecting 'non-match').
We could even be nice and have a "do not clear the test string when finished" option if we really wanted.
I think @OnlineCop has a good idea here about how such an implementation could work from a UX/UI standpoint. I would place the "import button" in the unit tests pane (at the bottom with the other 2 buttons perhaps?) so it does not clutter the "test string" view. That way, the people that actually use unit tests can benefit from the functionality, but it won't confuse new users.
As @firasdib said on IRC, the majority of people use only the most basic functionality of regex101. I'm not convinced it's worth while to get those people to start using unit tests and complicating their often basic use-cases needlessly.
Anchor your expression with ^$ and use /m, make sure your expression never match newline :D