8.18
randstr: Random String Generator
(require randstr) | package: randstr |
A library for generating random strings based on regex-like patterns.
1 Functions
Generate a random string based on the given pattern.
Examples:
(randstr "[a-z]{5}") (randstr "[0-9][a-z]+") (randstr "(abc|def)+")
Generate a list of n random strings based on the given pattern.
Examples:
(randstr* "[0-9]{3}" 5)
2 Pattern Syntax
The following pattern syntax is supported:
[abc] - Choose randomly from characters a, b, or c
[a-z] - Choose randomly from lowercase letters a through z
(abc|def) - Choose randomly between "abc" or "def"
a* - Zero or more of the preceding character
a+ - One or more of the preceding character
a? - Zero or one of the preceding character
. - Any character
3 Advanced Examples
In addition to basic pattern matching, the library supports more complex patterns:
(randstr "[[:alpha:]]{5}") (randstr "[[:digit:]]{3}") (randstr "[[:alnum:]]{4}") (randstr "[[:word:]]+") (randstr "[[:upper:]0-9]+") (randstr "[[:lower:]_]+") (randstr "[[:alpha:]0-9]+")
4 License
This project is licensed under the MIT License. See the "LICENSE" file for details.