-2

I want to check if another string matches with the following string:

'abc_xxxxxxxxxxxxx.txt'

e.g.

abc_20170926121600.txt would match

but

xyz_20170926121600.txt or abc_201709261216002323232323232323.txt would not match

omrakhur
  • 1,362
  • 2
  • 24
  • 48

1 Answers1

3

You want this:

abc_\d{N}\.txt

Where N is the number of digits.

yorah
  • 2,653
  • 14
  • 24
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • 5
    Technically you would need to escape the period with a \ too, otherwise it would match any single charachter between the digits and the 'txt'. – Gavin Jackson Oct 02 '17 at 14:29