Randexp.js: Create random strings that match a given regular expression
github.com
github.com
I mainly used it to generate test mail addresses. For example, the following will generate 36 test email addresses:
(blue|red|yellow|green).(oak|cedar|willow)@(yahoo.co.uk|google.com|example.org) - Generating all matching strings
- Generating a random matching string
- Counting the number of matching strings
- Simplification of regular expressions
https://github.com/asciimoo/exrex (AGPL licensed)Depending on what you really need (output string format, amount of numbers, non-additive links), you should find a hash function for your fit. You can always start by looking for youtube url hash.
Or does it not support lookahead?
\d{3}\-\d{3}\-\d{3}
Oops! I made a typo! That last 3 should be a 4. If I were tired, I could very easily see myself doing something like this. If I could put it into a tool and see 100 things which match it, I'd see very quickly that I messed something up."Regular expressions are used in every language, every programmer is familiar with them. Regex can be used to easily express complex strings. What better way to generate a random string than with a tool you can easily use to express the string any way you want?"
An example where this is useful (I guess) is generating data for tests. You can easily define an email regexp to generate random "valid" values for each model.