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

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

本文标签: javascriptRegex to filter out everything but a certain dateStack Overflow