From: Evertjan. on 4 Dec 2009 16:54 Tim Slattery wrote on 04 dec 2009 in comp.lang.javascript: > Thomas 'PointedEars' Lahn <PointedEars(a)web.de> wrote: > >>Tim Slattery wrote: >> >>> OK, assuming OP wanted to match strings of digits broken into groups >>> of 3 by dots, optionally followed by a comma then two digits: >>> >>> (\\d{1,3})(\\.\\d{3})*(\\,\\d{2})? >>> >>> For US numeric punctuation (12,345.67): >>> >>> (\\d{1,3})(\\,\\d{3})*(\\.\\d{2})? >> >>That would only work if it would be passed as content of a string >>value to RegExp(). But since there is no variable part in it, >>RegExp() is unnecessary, a RegExp initializer /.../ suffices (and you >>must not escape the escaping backslash there). >> >>Whether you try to escape the comma remains a mystery, too. > > It's a mystery to me too, but it wouldn't work without it. The weather will always remain a mystery to, it's raining cats and dogs, and my dog needs to go outside NOW. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
From: Thomas 'PointedEars' Lahn on 4 Dec 2009 16:00 Tim Slattery wrote: > Thomas 'PointedEars' Lahn <PointedEars(a)web.de> wrote: >> Tim Slattery wrote: >>> OK, assuming OP wanted to match strings of digits broken into groups >>> of 3 by dots, optionally followed by a comma then two digits: >>> >>> (\\d{1,3})(\\.\\d{3})*(\\,\\d{2})? >>> >>> For US numeric punctuation (12,345.67): >>> >>> (\\d{1,3})(\\,\\d{3})*(\\.\\d{2})? >> >> That would only work if it would be passed as content of a string value >> to RegExp(). But since there is no variable part in it, RegExp() is >> unnecessary, a RegExp initializer /.../ suffices (and you must not escape >> the escaping backslash there). >> >> Whether you try to escape the comma remains a mystery, too. > > It's a mystery to me too, but it wouldn't work without it. Yes, it would. PointedEars -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
First
|
Prev
|
Pages: 1 2 3 Prev: Strict mode eval code cannot instantiate variables or functions Next: www.sexpornnude.com |