LCCA
LCCA

Reputation: 3

RegEx to find all the file with a specific patter

I'm new on the regex and I'm trying to find all the files inside some folders. The files name are like this: B11102R-300x1608.jpg AT5020.jpg AT5045-1-1024x1024.jpg ABBIGLIAMENTO-324x130.jpg etc...

What I would like to is find all the files that have the images size append to it... so I'm trying to create a regex to show only file that contains this pattern -300x1608.jpg where of course the numbers are random.

I tried with this regex -(.*?). but it doesn't solve the problem since it select from the first - and thus it can find similar false positive match!

Could you help me? regards, Luca

Upvotes: 0

Views: 41

Answers (1)

JvdV
JvdV

Reputation: 75870

You could force a search for numbers:

^.*-\d+x\d+\.jpg$

See the demo.


  • ^ - Start string ancor.
  • .* - Any character other than newline zero or more times.
  • - - A literal hyphen.
  • \d+x\d+ - At least a single digit, a literal x and again at least a single digit.
  • \. - A literal dot (need to be escaped).
  • jpg - Literally match 'jpg'.
  • $ - End string ancor.

Upvotes: 1

Related Questions