javascript - Regex to filter out everything but a certain date - Stack Overflow

How can I create a javascript function which would filter out everything but a certain date in DD.MM.YY

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

Share Improve this question asked Mar 9, 2012 at 7:11 ttkalecttkalec 7411 gold badge7 silver badges26 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 4

This 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745322501a4622505.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信