Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Regular expression

23 views
Skip to first unread message

Tony

unread,
Apr 25, 2013, 12:16:23 PM4/25/13
to
Hello!

myDate has the following format ex. 2013/04/22 03:34
I want to use this pattern
var m = myDate.match(/^\d{4}-\d\d-\d\d (\d\d):(\d\d)$/),
hour = +m[1],
min = +m[2];

But before I can use this pattern
I need to change the - to / because the pattern works for format like
format ex. 2013-04-22 03:34

I have tried without luck.

//Tony

Arne Vajhøj

unread,
Apr 25, 2013, 4:01:16 PM4/25/13
to
This does not look like C# !!

Try something like:

.match(#^\d{4}[-/]\d\d[-/]\d\d (\d\d)[.:](\d\d)$#)

I am not good at JavaScript.

Arne

Tony

unread,
Apr 26, 2013, 6:50:59 AM4/26/13
to


"Arne Vajh�j" wrote in message
news:51798b8d$0$32115$1472...@news.sunsite.dk...
It was typo error from my side

//Tony

ALOK RAI

unread,
Aug 20, 2013, 7:40:25 AM8/20/13
to
On Thursday, April 25, 2013 9:46:23 PM UTC+5:30, Tony wrote:
> Hello! myDate has the following format ex. 2013/04/22 03:34 I want to use this pattern var m = myDate.match(/^\d{4}-\d\d-\d\d (\d\d):(\d\d)$/), hour = +m[1], min = +m[2]; But before I can use this pattern I need to change the - to / because the pattern works for format like format ex. 2013-04-22 03:34 I have tried without luck. //Tony

take a new var type variable and split mydate variable and again append in desire format...

0 new messages