Regular expression

  • Thread starter Thread starter Tony
  • Start date Start date
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
 
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
 
"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
 
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...
 
Back
Top