Regular expression

T

Tony

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
 
A

Arne Vajhøj

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.

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
 
T

Tony

"Arne Vajhøj" wrote in message

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.

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

It was typo error from my side

//Tony
 
A

ALOK RAI

Hello! myDate has the following format ex. 2013/04/22 03:34 I want to usethis 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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

need some finer tuning on the regular expression 9
Windows 7 Duplicate files. 1
regular expression 7
regular expression NxM 9
Regular expression 5
Regular expression 4
One more regular expression 4
regular expression 7

Top