I have an input date of 04122022 and i am using pattern matching to extract the date from a field but i would like to add slashes as the final results. 04/12/2022 to be inserted into a template metadata field. Does anyione has an example of the pattern match token that can be used?
Question
Question
Answer
Your regular expression has a typo and is missing a "]". The error is saying that square brackets have to be in pairs and that you have an opening bracket with no closing bracket. In your case, it's the last opening bracket.
^[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_([^_\d{4}(\d{4}+) ^
I would also recommend that you make your regular expression more specific, if possible, and also more concise. This is not possible for me to do without a lot more data, but just based on this data:
Watts Guardian Care, Inc._Ombudsman_11969601_2022_12_11_11_04221962
I'd guess you want something more like:
^[^_]+_[^_]+_\d{8}_\d{4}_\d{2}_\d{2}_\d{2}_(\d{8})
But, again, you might need to make that more specific (e.g., only letters in the second [^_]) or more general (e.g., allow various numbers of digits in the numbers).
Also, if that first name has an underscore, this pattern won't match correctly. You might want to check the "Clear token if no match is found" option so that the field ends up blank instead of having the token text.
Replies
It would be 3 patterns, one for each value you want to separate by slashes.
\d\d *First Result
\d\d(\d\d) *First Result
\d{4}(\d{4})
Now you have the 3 values your looking for and you can construct your final string. V1/V2/V3
Thanks Chad for this information. The 3 variables pulled the data back correctly but I am still unsure of how to combine the 3 variable into 1 variable in the tokens editor for quick fields so that i can populate a template metadata field. Can you help with combining the 3 into 1.
You can use a Substitution process to do this easily:
Pattern: (\d\d)(\d\d)(\d\d\d\d)
Replacement: ${1}/${2}/${3}
Thanks again Chad for this information. The subsitution token did work on the date alone. I hate to keep bothering you nut if you can clear up just a few more things for me. I am new at pattern matching and regular expression. Is it possible for you to provide futher guidance on resolving this issue. I really appreciate your help.
Below is the input data that i am working with and everything works fine up until the date portion. In my pattern i receive an unterrminated set error.
Test String is below with the date (04221962) as the last value that i am trying to figure out
Watts Guardian Care, Inc._Ombudsman_11969601_2022_12_11_11_04221962
When I test the pattern, i get the below error message and my template metadata is populate with the entire test string instead of the substitution token.
*** parsing "^[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_([^_\d{4}(\d{4}+)" - Unterminated [] set. ***
Substitution Token:
Template metadata assigned field
Your regular expression has a typo and is missing a "]". The error is saying that square brackets have to be in pairs and that you have an opening bracket with no closing bracket. In your case, it's the last opening bracket.
^[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_[^_]+_([^_\d{4}(\d{4}+) ^
I would also recommend that you make your regular expression more specific, if possible, and also more concise. This is not possible for me to do without a lot more data, but just based on this data:
Watts Guardian Care, Inc._Ombudsman_11969601_2022_12_11_11_04221962
I'd guess you want something more like:
^[^_]+_[^_]+_\d{8}_\d{4}_\d{2}_\d{2}_\d{2}_(\d{8})
But, again, you might need to make that more specific (e.g., only letters in the second [^_]) or more general (e.g., allow various numbers of digits in the numbers).
Also, if that first name has an underscore, this pattern won't match correctly. You might want to check the "Clear token if no match is found" option so that the field ends up blank instead of having the token text.
Thanks again Chad for all of your help. Recognizing my mistake in my regular expression and providing me with the correct expression seems to have cleared up all of my issues. Using the expression ou provided and the tip about the substitution token seems to have worked. Snippet below shows the input date that i was working with, the value of the substitution token and the template meta date in it's correct format with the slashes. I really appreciated your help with this.