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

Question

Question

Pattern Matching activity is not getting last 3 digits using \d{3}$ when running a workflow, but the test works

asked on September 10, 2020

I have a pattern matching activity that extracts multiple token fields from one string, queried from a database.

"SCR Number" is returned from a database query as S21001 (S + 2-digit fiscal year + 3-digit ID number).

I'm able to get the S and the 2-digit fiscal year, but not the 3-digit ID number. I tried both (\d{3})$ and \d{3}$, and they both work in the test window, but not when the workflow runs.

It should show 066 for the blue highlighted token below, but it just shows blank:

scrid holds the new token, for the next SCR number, which should be S21067. But, since it didn't get the ID number to increment, it just shows S21.

Any ideas?

0 0

Answer

SELECTED ANSWER
replied on September 10, 2020

Hi Mandi,

Is it possible there's whitespace at the end of that string? Wonder if that might give your expression some trouble with the end of input character being right after the 3 successive digits. That's been an issue for me before - the token I'm trying to extract something from has whitespace either at the beginning or end, and it throws off my expression, and it's hard to see in the Tokens tab of the workflow.

Does an expression of \d{2}(\d{3}) work? That'll identify a 2 digit string followed immediately by a 3 digit string, and only capture the last 3 digits. Not as clean as the expression you have, but might help narrow down if there's something at the end of the string you're trying to extract from. Not sure how it'll affect the rest of your workflow, though, with your token calculator.

2 0

Replies

replied on September 10, 2020

That was it... the database field was set as an nchar(10). Set it to an nvarchar(6), removed the trailing spaces and reran the workflow. It worked! Thanks so much!! I didn't think the solution would be in the database. smiley

2 0
replied on September 11, 2020

Side note: this workflow can generate duplicate numbers. (Workflow is multi-threaded, so multiple copies of this workflow could run at the same time, reading the same value from the database)

1 0
replied on September 14, 2020

Is there a way to avoid duplicate numbers?

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

Sign in to reply to this post.