0

I am trying to create a regular expression pattern in C# which allow you to have

next pattern: _DXX at the end of your .

Example :

04R5714A_D15 is correct

04R5714A_D05 is incorrect

04R5714A_D5 is correct

I tried : .*_D([1-9]{1}[0-9]?) but it didn't work :

Vlad Iobagiu
  • 4,118
  • 3
  • 13
  • 22

1 Answers1

1

.*_D[1-9]\d?$ should work for you.

Demo

.* catches everything up until your underscore

_D is a literal match

[1-9] matches one number in that range

\d? matches 0 or 1 single number (0-9)

$ is the end of the string

emsimpson92
  • 1,779
  • 1
  • 9
  • 24