Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19482

Re: Regular expression

From "Tony" <tony.johansson@inport.com>
Newsgroups comp.lang.javascript
Subject Re: Regular expression
Date 2013-04-26 11:27 +0200
Organization A noiseless patient Spider
Message-ID <kldh3k$u49$1@dont-email.me> (permalink)
References <klbk00$8ks$1@dont-email.me> <4fcb1664-8b09-4961-863d-e1232eccef64@n4g2000yqj.googlegroups.com>

Show all headers | View raw



"Scott Sauyet"  wrote in message 
news:4fcb1664-8b09-4961-863d-e1232eccef64@n4g2000yqj.googlegroups.com...

On Apr 25, 12:04 pm, "Tony" <tony.johans...@inport.com> wrote:

> myDate has the following format ex. 2013/04/22 03:34 [ ... ]
> I get runtime error [ ... ]
> var m = myDate.match(/^\d{4}\/\d\d\/\d\d (\d\d):(\d\d)$/),
>              hour = +m[1],
>              min  = +m[2];
> [ ... ]

Can you describe the runtime error you see, and the environment?  This
code works fine for me:

    var myDate = "2013/04/22 03:34";
    var m = myDate.match(/^\d{4}\/\d\d\/\d\d (\d\d):(\d\d)$/),
        hour = +m[1],
        min  = +m[2];

and sets `hour` to 3 and `min` to 34.  I only tested in  Chrome's
console, but at a casual glance I can't see any reason it shouldn't
work in other environments.

  -- Scott

It was typo error from myself

//Tony 

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Regular expression "Tony" <tony.johansson@inport.com> - 2013-04-25 18:04 +0200
  Re: Regular expression Scott Sauyet <scott.sauyet@gmail.com> - 2013-04-25 10:07 -0700
    Re: Regular expression "Tony" <tony.johansson@inport.com> - 2013-04-26 11:27 +0200
  Re: Regular expression Denis McMahon <denismfmcmahon@gmail.com> - 2013-04-25 18:05 +0000
    Re: Regular expression Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-25 21:02 +0200
    Re: Regular expression Scott Sauyet <scott.sauyet@gmail.com> - 2013-04-26 11:15 -0700
      Re: Regular expression Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-26 21:17 +0200

csiph-web