I want to match filenames with date format and ANY extension . Is following regex good for this:
[0-9]{2}.[0-9]{2}.[0-9]{4}(?:\..*)?
??
Above regex, although seems to work, does not return this string in result: "12.1.1990.txt"
How to write regex which also includes dates like either
12.12.2203.bmp
or
1.11.2005.txt
or
12.1.2006.bin
?
Thanks. And ps. where to find further info on writing these expressions?
尝试这个 -
[0-9]{2}.[0-9]**{1,2}**.[0-9]{4}(?:\..*)?
I'd go for this regex:
\d{1,2}.\d{1,2}.\d{4}(?:\.\w*)?
Also, I'm using some online regex tools for checking my regex, which is very handy on checking specific things (not to advertise or anything).
By this website, FileExt , DOS illegal characters in file extension are this: |<>\\^=?/[]";* plus control characters, so changing the file extension regex to this one: (?:\\.[^\\|\\<\\>\\\\\\^\\=\\?\\/\\[\\]\\"\\;\\*\\.]*)?
will match valid file extensions.
The final regex would be: \\d{1,2}.\\d{1,2}.\\d{4}(?:\\.[^\\|\\<\\>\\\\\\^\\=\\?\\/\\[\\]\\"\\;\\*\\.]*)?
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.