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



Need to use either RegEx or Patter Matching to Add Hyphens in token value

asked on September 11, 2017 Show version history



I have been trying to work on adding hyphens between a specific amount of numbers in a sequence. 


We can use the example of a PO #.


For instance, I have the following PO number being captured by RegEx already in Quick Fields




The dot and the asterisk are just quick fields not reading the hyphen correctly. In reality the value should be 




It is always an alphanumeric group of 4, then another one, and then another one all seperated by a hyphen in between each group of four.


Does anyone know the easiest way to go about doing this?



0 0


replied on September 11, 2017 Show version history

Does it always come back with a "." or a "*" from Quick Fields? If that is a consistent result, you could bypass regex and pattern matching all together and use the following:


This will split on those two characters (I tested it and the order didn't mess up the sequence of the alphanumeric values so it should work either way).

The "Split" functions break the values into a multi-value token for each section, then it joins them all back together with a "-" between each chunk.

Each of the following values yielded TYC2-96TE-5RT5

  • TYC2*96TE*5RT5
  • TYC2*96TE.5RT5
  • TYC2.96TE.5RT5
  • TYC2.96TE*5RT5


However, if there's too much variation in the characters Quick Fields returns or you just don't want to risk it coming back with something unexpected, you could use the following Pattern with "All matches (as a multi-value token)".

Then, use "modify token" in a separate activity to join each chunk together with a "-"

2 0
replied on September 12, 2017

This is awesome Jason! To answer your question though, the value does not always come back with a "." or a "*", it typically should come back with a "-"


Your idea for a split probably will work but if I want to incorporate the "-" as well since usually values will come back with at least one hyphen, what can I do to update the formatted token to accommodate for that?





0 0
replied on September 12, 2017

Either of these should still work even if the value comes back with one or more hyphens.

The first option only splits on "*" or "." so it will leave the hyphens alone. For example, A123-B456*C789 would only split into A123-B456 and C789, then join back together with a hyphen between the two sections.

The second option doesn't look at the separating characters at all, so it will always break it into alphanumeric segments of 4-characters, which you would then join together with hyphens.

1 0
replied on September 12, 2017

So I went with the second option since it is not always a ".", or a "*". I thought I set up everything correctly but when I do my testing, as you can see in the screen shot, the values are not being seperated. Is there anything I could be missing?


I have my token of tkInvoice#PatternMatch set to "All matches (As a multi-value token)



Modify Token.jpg
Modify Token.jpg (69.25 KB)
0 0
replied on September 12, 2017 Show version history

You won't be able to test that way. The pattern match splits it, and the token update joins it back together, but they are separate processes so when you put a test value into the token editor it is only testing that portion.

To test the full process, first test the initial value in the pattern matching activity, copy the output, then test that value in the token updater.

1 0
replied on September 12, 2017

So I have gone ahead and tested the pattern matching process first and that seems to work fine. It seperates the values into something like:

TYC2; 96TE; 5RT5


(I have provided a screen shot of this)


Then what I have done is created another activity after the pattern matching called "Assign Token Value"


(Screen shot of this provided)


In that activity, I have selected modify and updated the information in the first window (screen shot called Configure Token shows what I have added)


I am not sure if this is exactly how it should be set up though as I am not able to test in the token editor of the second activty successfully.


I appreciate all the help so far, I think I almost have it but must be missing something small.









Configure Token.jpg
Testing.jpg (162.99 KB)
0 0
replied on September 12, 2017

Everything looks good. The problem is not that it isn't working, it's that you can't really pass the true result value of one test activity to another, especially a multi-value.

You could test this more easily in workflow by creating the same activities, just start with a set test value. This really should work the way you have it now, the problem is just how to test it effectively.

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

Sign in to reply to this post.