Patt Khwela
Patt Khwela

Reputation: 11

Regex pattern for a number and letter combination in string

I'm having trouble with my regex for finding all directories with a number and letter in the title.

Basically in //"E:\SomeProvider\SomeGame\build\images\1136x640\img.png" I am looking for an output of //"1136x640"

Upvotes: 1

Views: 82

Answers (1)

dquijada
dquijada

Reputation: 1699

Without a better set of examples or explanation, this is the best regex I can think of:

[^\\/]*(?:[a-zA-Z][^\\/]*\d|\d[^\\/]*[a-zA-Z])[^\\/]*

Basically it matches everything that is not \ or / that contains a letter and a number after, or vice versa.

You can see a more detailed explanation here and test your own examples.

Upvotes: 1

Related Questions