Earth
Earth

Reputation: 3571

One expression to support different format strings

Sample Format

-q12345(x666)-55_data.jpg

I tried with ([\w/-]+)\.jpg and it returns only -55_data.jpg. Actually, I need to get the whole value that is -q12345(x666)-55_data.jpg.

Also, I need the same expression to support following formats. Is that possible. Thanks.

123-55-FULLY_DAT.jpg

456-67-TABLE-OPEN_SMA.jpg

12431-56-78-Q789-RA-R-Z_DETAIL.jpg

E811-33-25(7)-98Z(5)-44-79-34_LARGE.jpg

UTE_B70000-94-65-15-56-25-06-46-16_HEAVY.jpg

Upvotes: 0

Views: 32

Answers (2)

vks
vks

Reputation: 67968

((?:-?[\w)()]+-)*[\w]+\.jpg)

Try this.See demo.

http://regex101.com/r/qC9cH4/6

Upvotes: 1

Avinash Raj
Avinash Raj

Reputation: 174696

Remove the forward slash and add () inside the character class,

([\w()-]+)\.jpg

DEMO

Upvotes: 1

Related Questions