Hacker News new | past | comments | ask | show | jobs | submit login

Would be ultra-cool if you could propose a "generate a matching sample" button.



Take a look at http://fent.github.io/randexp.js/ if you want something that will do this


I have thought about this, but in cases where it would be useful, it's impossible to generate a sample match string. For example, creating a match string for /(?:a|[bc])efg?/ is super simple, but for something like: /(ab(?1)*)/ it becomes much harder. Not to mention the performance hit you would see for these more complex expressions. (These are just dummy expressions for illustrative purposes, but I'm sure you get my gist.)


If there is a modifier with a variable number like ?,+,* you could just repeat it X times.

For example if it is ? repeat 1 time, + repeat 2, * repeat 3 etc...

If it is |, choose the first or choose randomly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: