1 | # template
|
2 |
|
3 | Return a random string matching the given template.
|
4 |
|
5 | ```js
|
6 | // usage
|
7 | chance.template('{AA####}')
|
8 | => 'ZQ7803'
|
9 | chance.template('{Aa}-{##}')
|
10 | => 'Vr-78'
|
11 | chance.template('{####}:{####}:{####}')
|
12 | => '1628:5987:7803'
|
13 | ```
|
14 |
|
15 | The template consists of any number of "character replacement" and "character
|
16 | literal" sequences. A "character replacement" sequence starts with a left
|
17 | brace, has any number of special replacement characters, and ends with a right
|
18 | brace. A character literal can be any character except a brace or a backslash.
|
19 | A literal brace or backslash character can be included in the output by
|
20 | escaping with a backslash.
|
21 |
|
22 | The following replacement characters can be used in a replacement sequence:
|
23 |
|
24 | * "#": a random digit
|
25 | * "a": a random lower case letter
|
26 | * "A": a random upper case letter
|
27 |
|