Using Groovy, I’d like to generate a random sequence of characters from a given regular expression.
- Allowed charaters are:
[A-Z0-9] - Length of generated sequence: 9
Example: A586FT3HS
However, I can’t find any code snippet which would help me. If using regular expressions is too complicated, I’ll be fine defining the allowed set of characters manually.
If you don’t want to use apache commons, or aren’t using Grails, an alternative is:
but again, you’ll need to make your
alphabetyourself… I don’t know of anything which can parse a regular expression and extract out an alphabet of passing characters…