Regex to Extract Pdf Page (same number Pattern)

Hello,

I am trying to create a Regex that can validate a number with himself in one single code.

I know a few workarounds are possible but I would like to verify if this type of functionality is possible with regex.

Example:

Page 11/12 (should not validate) as 11 !=12
Page 12/12 (should validate) as 12 = 12
Page 1/12 (should not validate) 1 !=12

Best regards,

Octavio Elliot

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.IsMatch("Page 12/12","Page (\d+)/\1(?=\D|$)")

System.Text.RegularExpressions.Regex.IsMatch("Page 1/12","Page (\d+)/\1(?=\D|$)")

Regards,

This is precisely what I need!

Thank you very much!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.