I want to have a range between 0 to 65536 , what would be the regular expression for that?
ok sorry i forget to mention that i want it in jquery
mazhar kaunain baig
2010-09-14 12:33:45
@mazhar: JQuery changes neither the fact that regexps are not suited for this nor does it change if statements.
Deniz Dogan
2010-09-14 12:36:12
`((0...65536) === i)`
Nakilon
2010-10-31 17:13:38
+1
A:
A regular expression really isn't well suited to this sort of validation. Gareth's answer provides a much more sensible solution.
If, for some reason, you absolutely have to use a regex then it will probably look something like this:
^(?:[0-5]?[0-9]{1,4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-6])$
LukeH
2010-09-14 12:42:07
+1
A:
See also this question, which asks pretty much the same thing, and got pretty much the same answer. (ie don't use regex for this!)
Spudley
2010-09-14 16:08:37