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

Question

Question

Extract last 4 Digits with Token Editor

asked on March 1, 2018

I am in the workflow designer and for one of the fields I want to extract the last 4 digits from a 9 digit number. I have used the regular expression (\S\S\S\S), but it extracts the first 4 numbers. How would I get it to take the last 4?

0 0

Replies

replied on March 1, 2018 Show version history

Another option is \d{4}$

The \d{4} portion tells it to find a 4-digit number string and the $ tells it to start from the end

 

Just make sure you are putting the result in a String token, or enforce 4-digit formatting when you read the result, if you need to preserve leading zeros.

If you have a number like 123450123, the regex above will give you 0123, but if you store that result as a number you'll end up with 123.

2 0
replied on March 1, 2018 Show version history

Hi Bradley,

 

Try this: 

.*(\d\d\d\d)

Rick

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

Sign in to reply to this post.