I have 2 regular expressions which I want to check invoice description against, these seem to work just fine in airtable but are not picked up by text parser match pattern module. Any idea why?
The 2 patterns I’ve got are:
Strings I need to match:
MH42-JQ47-XM39 or PG55-XP73-KY73-X0001
Always composed by 2 letters followed by 2 digits separated by dash, but sometimes there’s 4 extra characters at the end (numbers or letters).
You’re using a non-capturing group in your regular expressions and the text parser won’t bring back and match as a result. The parser, parses, so it has to use a capturing group to extract data.
This expression will match 4 or 5 groups of words followed by a - zero or more times. It will work on your pattern and even allow the last part to be 4 letters or have a trailing - which you may not want. But it will capture each part of your description and you can concatenate the groups in a subsequent variable.
There’s probably a better regex to capture the whole description in one group, but one would need to spend a bit more time in regex101.com to figure it out.
Edit: yup this one would capture the whole description in one group and if you have a trailing 5 letter code that would be in a second group. The groups can be nested and this last group is optional, due to the ? mark.