简体   繁体   中英

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"

thanks

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.


EDIT: If you add some more input>output examples and your regex we can probably find a better fit, and, more importantly, help you understand why your regex isn't working.

EDIT2: Whoever downvoted, if you could explain the problem with the answer I will fix it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM