Enzo wrote on 30 aug 2005 in comp.lang.javascript:
> Hi Evertjan,
>
[quoted text clipped - 4 lines]
> for 1 to 3 decimals, but I need to replace
> the static values '1' & '3' with variables.
myTestValue = 1.1234
a = 1
b = 3
myRegex = "^-?\\d+\\.\\d{"+a+","+b+"}?$"
re = new RegExp(myRegex,"");
alert( re.test(myTestValue) )

Signature
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Enzo - 30 Aug 2005 16:04 GMT
Works great! Thanks Evertjan!
Enzo
JRS: In article <1YXQe.3343174$I96.3853437@telenews.teleline.es>, dated
Tue, 30 Aug 2005 12:05:17, seen in news:comp.lang.javascript, Enzo
<yuyu@yuyu.com> posted :
>I tried this pattern:
>
>/^-?\d+(\.\d{1,3})?$/
>
>for 1 to 3 decimals, but I need to replace
>the static values '1' & '3' with variables.
Unless this is school work, you do not *need* to replace the values,
since you can also use (\.\d+) and test the length of the match.
<URL:http://www.merlyn.demon.co.uk/js-valid.htm>

Signature
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.