Description
The SubStringGen returns a substring of characters within a larger string of characters. This generator returns the substring in two variants:
- substring (int beginIndex)
- substring (int beginIndex, int endIndex)
For example, it can reference card numbers and then return the last four digits of each card number.
- 5210000000001293 would become 1293
In This Article
- Video Tutorial
- Use Case Examples
- Generator Parameters
- Example 1 - Generate the Last 4 Digits of Referenced Credit Card Number
- Example 2 - Generate the Birth Month and Day from a Referenced Birthdate
Video Tutorial
Please take a few seconds to watch the tutorial video below.
Use Case Examples
Here are some use case examples for the SubStringGen:
- Return the last four digits of a phone number.
- Return the last four digits of an SSN.
- Remove a prefix from a value (e.g., ID-67843, TRK-78234).
- Use a portion of a product name, code, or label.
- Return only the date portion from a timestamp.
- Isolate a department code from an Employee ID.
Generator Parameters
Items with an asterisk* are required.
- reference* - Defines the attribute or literal to reference.
- beginIndex* - Defines the position in the string to begin. The position is zero-based, meaning the first character in the string is in position 0.
- endIndex - Defines the position in the string to end. The ending position is always -1.
- ignoreBound - Defines whether to ignore the out-of-bound exception error for the cases where the string's length is shorter than the endIndex.
Example 1 - Generate the Last 4 Digits of Referenced Credit Card Number
This example demonstrates the setup for the video example above. It will generate the last four digits of the referenced credit card numbers. Two generators, CreditCardGen and SubstringGen, will be linked in this example.
Note: You could also reference an Attribute or use a constant value for the reference parameter in the SubstringGen.
Sample Output
The FourDigit value will be the generated output.
CreditCardGen
Generates a 16-digit Visa credit card numbers that increment by 100 each iteration.
SubstringGen
References the CreditCardGen above to generate the last four digits of each credit card number.
Example 2 - Generate the Birth Month and Day from a Referenced Birthdate
This example shows how to generate the birth month and day from a referenced birthdate. It will use the FlexibleDateRangeGen and the SubstringGen.
Sample Output
The MonthDay value will be the generated output:
FlexibleDateRangeGen
Generate a birthday date where the first record will start on 01/01/1950 and increase yearly on each iteration up to 75 years. The birth month and day are randomized.
- format = MM/dd/yyyy
- startDate = 01/01/1950
- endRange = 75 years
- nextBy = Year
- randomizeMonthDay = MonthDay
SubstringGen
References the FlexibleDateRangeGen above for the birthdate to generate only the month and day values as the output by starting at the 0 index position and ending at the 5 index position.