-1

I would like to match the following list of files with a single PCRE regex pattern

27919506_7368.jpg
27965477_68.jpg
52345652_1-4.jpg
65849674_245.jpg
54839756_34-9.jpg

What I've come up to so far is this \d{8}_\d{1,4}\.jpg, however, this fails to match the -\d+ variations...

Likewise, this \d{8}_\d{1,4}-\d+\.jpg fails to match the non -\d+ variations...

What would the correct pattern be that would match all of the above?

Faye D.
  • 833
  • 1
  • 3
  • 16

1 Answers1

1

You can use the regex, \d{8}_[\d-]{1,4}\.jpg.

  • \d{8}_: Matches eight digits followed by _
  • [\d-]{1,4}: Matches a digit or -, one to four times
  • \.jpg: Matches .jpg
Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110