admin管理员组文章数量:1420981
How can I create a javascript function which would filter out everything but a certain date in DD.MM.YYYY format?
Example:
08.03.2012.
četvrtak, 8.3.2012. 14:25
Četvrtak, 08.03.2012 22:19
08.03.2012 13:13
08.03.2012 / 20:04
08.03.2012., 20:41
08.03.2012 19:02
everyone of these needs to return 08.03.2012
How can I create a javascript function which would filter out everything but a certain date in DD.MM.YYYY format?
Example:
08.03.2012.
četvrtak, 8.3.2012. 14:25
Četvrtak, 08.03.2012 22:19
08.03.2012 13:13
08.03.2012 / 20:04
08.03.2012., 20:41
08.03.2012 19:02
everyone of these needs to return 08.03.2012
2 Answers
Reset to default 4This actually could be better :)
/\b\d{1,2}\.\d{1,2}\.\d{4}\b/
Try this
\b\d{1,2}\.\d{1,2}\.\d{4}\b
See it here on Regexr
But this is checking only the format, not if this is a valid Date!
\b
is a word boundary to avoid partial matches
\d
is a digit
{n,m}
is a quantifier, requiring a min of n and a max of m
本文标签: javascriptRegex to filter out everything but a certain dateStack Overflow
版权声明:本文标题:javascript - Regex to filter out everything but a certain date - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745322500a2653440.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论