You are viewing limited content. For full access, please sign in.

Question

Question

Format Hyphenated Number to 4 Digits

asked on July 27

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

0 0

Replies

replied on July 28 • Show version history

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

1 0
replied on July 27

Use pattern matching to break it up into 2 values and then format them individually and reconstitute the hyphenated string. 

0 0
replied on July 30 • Show version history

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 = 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.