I have a hyphenated number that need to be 4 digits before and after the hyphen. This unformatted number is an input value on a WF.
For example
1. 456-2 → 0456-0002
2. 12-345 → 0012-0345
3. 1-1 → 0001-0001
Any suggestions on how I achieve it
I have a hyphenated number that need to be 4 digits before and after the hyphen. This unformatted number is an input value on a WF.
For example
1. 456-2 → 0456-0002
2. 12-345 → 0012-0345
3. 1-1 → 0001-0001
Any suggestions on how I achieve it
You could use Regex to break it up into 2 tokens, using the '-' as the delimiter, such as:
^(.*?)- for getting the values before the hyphen
-(.*) for getting the values after the hyphen
then use Assign Token Values or Token Calc to manipulate them to be 4 digits with leading 0's using the following syntax:
%(PreHyphenToken#"D4"#) and %(PostHyphenToken#'D4'#)
You can then combine your 2 tokens back into a complete token with the hyphen and return that as an output parameter
Use pattern matching to break it up into 2 values and then format them individually and reconstitute the hyphenated string.
Another way is to just use token manipulation via Assign Tokens, but based on Miruna's post.
Original number = 456-2
Create a separate token for each part
Part1 with formatting:
%(Original Number#@Split(-)@##[1]##"0000"#)
Part2 with formatting:
%(Original Number#@Split(-)@##[2]##"0000"#)
Combine Part1 and Part2:
Result =