You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A library and command line tool that can be used to generate data for testing, templating and other uses. You provide it with a pattern containing symbols defining the output you want to produce and it will create random data to match that pattern.
@@ -45,50 +45,50 @@ The following symbols are shorthand tokens which you can use in your generation
45
45
### Groups
46
46
Groups can contain multiple Symbols or characters and allows us to treat them as a single unit. Their usage becomes apparent when using them with *repetitions* or *alternations*. Groups are surrounded in () brackets.
47
47
#### Simple Groups
48
-
-`(\d)` - A number between 0 and 9 e.g. '8'
49
-
-`(ABC\d)` - 'ABC' followed by a number between 0 and 9 e.g. ABC7
50
-
-`\L(\d)\L` - A upper-case letter, three digits between 0 and 9 and another upper-case letter e.g. H2O
48
+
-`(\d)` - A number between 0 and 9 e.g. '2'
49
+
-`(ABC\d)` - 'ABC' followed by a number between 0 and 9 e.g. ABC1
50
+
-`\L(\d)\L` - A upper-case letter, three digits between 0 and 9 and another upper-case letter e.g. M7R
51
51
52
52
#### Alternations
53
53
When a group contains alternations the patterns are divided by the | character, during processing one of the alternated patterns is selected at random.
54
54
Groups can contain several individual symbols or groups of symbols and randomly alternate between them when generating the output value.
55
55
56
56
**Alternatives must be contained within a Group**
57
-
-`(\L\L|\d\d)` - Either two upper-case letters OR two numbers e.g. 'RX'
58
-
-`(\L\L|\d\d|[AEIOU]|[100-120])` - Either two upper-case letters OR two digits OR an upper-case vowel OR a number between 100 and 120 e.g. 'U'
57
+
-`(\L\L|\d\d)` - Either two upper-case letters OR two numbers e.g. 'JY'
58
+
-`(\L\L|\d\d|[AEIOU]|[100-120])` - Either two upper-case letters OR two digits OR an upper-case vowel OR a number between 100 and 120 e.g. 'QA'
59
59
-`(\C|)` - Either a upper-case Consonant or nothing.
60
60
61
61
### Ranges
62
62
Ranges can contain multiple characters or ranges of characters but no symbols (the items defined within the range will be what is used, no special symbols are allowed). The item to be produced is selected at random.
63
63
#### Character ranges
64
-
-`[abc]` - Either 'a','b' or 'c' e.g. 'b'
65
-
-`[a-z]` - A single lower-case letter between a and z e.g. 'v'
66
-
-`[A-Z]` - A single upper-case letter between A and Z e.g. 'D'
67
-
-`[A-D]` - A single upper-case letter between A and D e.g. 'D'
68
-
-`[A-Da-z]` - A single character between A and D or between a and z e.g. 'n'
64
+
-`[abc]` - Either 'a','b' or 'c' e.g. 'a'
65
+
-`[a-z]` - A single lower-case letter between a and z e.g. 'z'
66
+
-`[A-Z]` - A single upper-case letter between A and Z e.g. 'R'
67
+
-`[A-D]` - A single upper-case letter between A and D e.g. 'C'
68
+
-`[A-Da-z]` - A single character between A and D or between a and z e.g. 's'
69
69
70
70
#### Numeric ranges
71
-
-`[1-5]` - A number between 1 and 5 e.g. '3'
72
-
-`[100-500]` - A number between 100 and 500 e.g. '161'
73
-
-`[1.25-5]` - A decimal number between 1.25 and 5. The scope or number of decimal places is taken from the first number defined (1.25 in this case) and the produced value will have the same number of decimal places. e.g. '3.39'
71
+
-`[1-5]` - A number between 1 and 5 e.g. '1'
72
+
-`[100-500]` - A number between 100 and 500 e.g. '253'
73
+
-`[1.25-5]` - A decimal number between 1.25 and 5. The scope or number of decimal places is taken from the first number defined (1.25 in this case) and the produced value will have the same number of decimal places. e.g. '1.89'
74
74
75
75
### Named Parameters
76
76
A named pattern is surrounded with @ characters and links to a predefined pattern loaded from a file. The `default.tdg-patterns` file located in the same directory as the tdg executable file contains a list of named patterns which can be used in other patterns you write. For example to generate you could write something like `([1-9]\d\d-\d\d-\d\d\d\d)` or you can use the named parameter in the file `(@misc_ssn@)` to a similar value. You can add more patterns to the file as you wish. Named patterns can also include other named patterns if you so wish.
77
77
78
-
Take a look at the `@address_us_type1@` pattern in the file as an example of a compound pattern than uses other patterns to produce an output e.g. '5376 Pleasant Lane, Stafford County, Oregon, 68443'
78
+
Take a look at the `@address_us_type1@` pattern in the file as an example of a compound pattern than uses other patterns to produce an output e.g. '8579 Shady Lane, Howard County, Montana, 52963'
79
79
80
80
### Repetition
81
81
Repetition is a powerful feature allowing for complicated data production. A Symbol, Group or Range can be repeated a set or random number of times by using the following syntax.
82
82
83
83
#### Quantity Repetition
84
-
-`\d{5}` - Will generate 5 number characters e.g. '74910'
85
-
-`(\L\d\L){5}` - Will generate 5 upper-case letter, number, upper-case letter items e.g. 'Z8XA2AU8QU6QI2M'
86
-
-`[ABC]{5}` - Will generate 5 items where each item will be either 'A','B' or 'C' e.g. 'ACCBA'
84
+
-`\d{5}` - Will generate 5 number characters e.g. '46642'
85
+
-`(\L\d\L){5}` - Will generate 5 upper-case letter, number, upper-case letter items e.g. 'J5EJ6KE9CZ4QB1F'
86
+
-`[ABC]{5}` - Will generate 5 items where each item will be either 'A','B' or 'C' e.g. 'AABAC'
87
87
88
88
#### Random Quantity
89
-
-`\d{5,10}` - Will generate between 5 and 10 number characters e.g. '39296896'
90
-
-`(\L\d\L){5,10}` - Will generate between 5 and 10 upper-case letter, number, upper-case letter items e.g. 'A5UQ4QI1NB8YE4AZ5GA0B'
91
-
-`[ABC]{5,10}` - Will generate between 5 and 10 items where each item will be either 'A','B' or 'C' e.g. 'BCBCCCAB'
89
+
-`\d{5,10}` - Will generate between 5 and 10 number characters e.g. '7211494791'
90
+
-`(\L\d\L){5,10}` - Will generate between 5 and 10 upper-case letter, number, upper-case letter items e.g. 'I0MJ3JA6VW7CA8FW4HD1J'
91
+
-`[ABC]{5,10}` - Will generate between 5 and 10 items where each item will be either 'A','B' or 'C' e.g. 'BBAAAAB'
92
92
93
93
94
94
## Template Syntax
@@ -98,7 +98,7 @@ You can create template documents that contain multiple pattern syntax placehold
98
98
99
99
### Placeholders
100
100
You can place your symbols and patterns within placeholders which will be replaced with the generated values. These placeholders contain 1 or more symbols representing the desired output characters.
101
-
Within a template all text not within a placeholder is treated as normal text with no special handling taking place. Patterns that need to be randomly generated should be placed inside '<< >>' tokens e.g. 'This is a template <<\L\L>>' produces 'This is a template DW'. You can also escape placeholders by placing a '\' before them which will prevent them from being processed. To place a '\' before a placeholder in the generated content you need to place 2 backslashes before the placeholder.
101
+
Within a template all text not within a placeholder is treated as normal text with no special handling taking place. Patterns that need to be randomly generated should be placed inside '<< >>' tokens e.g. 'This is a template <<\L\L>>' produces 'This is a template TE'. You can also escape placeholders by placing a '\' before them which will prevent them from being processed. To place a '\' before a placeholder in the generated content you need to place 2 backslashes before the placeholder.
102
102
103
103
### Configuration
104
104
You can supply configuration values to the generator either as an additional parameter within the api or you can include it within the template string itself by wrapping it within '<# #>' tokens. Configuration directives must appear as the first item with a template or else they will be ignored and removed.
@@ -134,23 +134,23 @@ Pattern files contain Named Patterns which can be used within Templates. TDG com
134
134
### Commandline examples
135
135
- Single repeating symbols using the following syntax
136
136
-`tdg -t 'Letters <<\L{20}>> and Numbers <<\d{12}>>'`
137
-
- Produces items like *'Letters EGTCWRTVAOIIGRDMEACQ and Numbers 963398177619'*.
137
+
- Produces items like *'Letters DWZIZQWSYOREAADBHFCY and Numbers 489186903271'*.
138
138
- Repeating patterns containing multiple letters or numbers of random length.
139
-
-`tdg -t '<<(\L){5}>>'` - Will generate 5 random upper-case characters. e.g. *'YBTXR'*
140
-
-`tdg -t '<<(\L\L\d){24}>>'` - Will generate 24 repeating letter-letter-number values e.g. *'YC8NE0MI2RV5LN9LN9OY3CA4YC3KJ4FX2UG9FC7OV0TD3HH1EN4CF9IV0KO0QC9VM9HR2BF4'*
139
+
-`tdg -t '<<(\L){5}>>'` - Will generate 5 random upper-case characters. e.g. *'CRQGA'*
140
+
-`tdg -t '<<(\L\L\d){24}>>'` - Will generate 24 repeating letter-letter-number values e.g. *'OG2QP1PR3JN1ZW0JV7IW8MH7UJ7UN0IK8BS9WH8QK4NI3WI3RV2ZI3EC9MV2LU1GA1HY1CM5'*
141
141
- Variable length data can be generated also
142
-
-`tdg -t '<<(\L){10,20}>>'` - Will generate a string containing between 10 and 20 characters of random value e.g. *'ZDHJWERVHFWZ'*
143
-
-`tdg -t 'Letters <<\L{2,20}>> and Numbers <<\d{2,12}>>'` produces items like *'Letters SHLL and Numbers 85697196496'*
142
+
-`tdg -t '<<(\L){10,20}>>'` - Will generate a string containing between 10 and 20 characters of random value e.g. *'RLLYYJXBKCRVJBNXQAJ'*
143
+
-`tdg -t 'Letters <<\L{2,20}>> and Numbers <<\d{2,12}>>'` produces items like *'Letters QFQGHIFPJEP and Numbers 71697'*
144
144
- Input can contain several placeholders.
145
145
-`tdg -t 'Hi there <<\L\v{0,2}\l{0,2}\v \L\v{0,2}\l{0,2}\v{0,2}\l{0,2}\l>> how are you doing? Your SSN is <<[1-9]\d\d-\d\d-\d\d\d\d>>.' -c 100`
146
-
- Produces 100 items like *'Hi there Va Xamw how are you doing? Your SSN is 480-83-2018.'*
146
+
- Produces 100 items like *'Hi there Eu Emkabnc how are you doing? Your SSN is 114-81-6613.'*
147
147
- Generate 100 SSN like values and output to console window.
148
148
-`tdg -t '<<[1-9]\d\d-\d\d-\d\d\d\d>>' -c 100`
149
-
- Produces 100 items like *'485-03-1427'*.
149
+
- Produces 100 items like *'353-02-4514'*.
150
150
- Generate 100 strings with random name like values and output to file.
151
151
-`tdg -t 'Hi there <<\L\v\l\v \L\v\l\l\v\v\l\l\v>> how are you doing?' -c 100 -o C:\test1.txt`
152
-
- Produces 100 items like *'Sala Nufniizqi'*.
153
-
-`tdg -t '<<Letters \w{2,20} and Numbers \d{2,12}\n>>'` produces the following output: *'Letters xI3bgtn9Bb37lui and Numbers 800410
152
+
- Produces 100 items like *'Aepi Euuwoavio'*.
153
+
-`tdg -t '<<Letters \w{2,20} and Numbers \d{2,12}\n>>'` produces the following output: *'Letters nR9mhIGy_KE and Numbers 1134618008
154
154
'*
155
155
156
156
## This README was generated using the generator. See the unit tests for other examples.
0 commit comments