Regex to check if filename format was followed and extract number

Hi @mnlatam

I think I have a solution for you. Check out this pattern

Regex Pattern: “\b(\d{12})_\w\.(jpg|pdf)”

Explanation - it will match on:
12 digits only
followed by an underscore “_”
then a single word character (not just a,b or c)
then a “.”
Then the file formats are in brackets, the “|” symbol essentially means either/or. So it can be both jpg or pdf.

To get the 12 digit number you need to use group 1.

To get Group 1:
INSERT_REGEX_OUTPUT_VARIABLE(0).Groups(1).ToString
And update/replace capital letters.

Hopefully this helps :slight_smile:

Checkout my Regex MegaPost if you want to learn Regex

Cheers

Steve

2 Likes