Regular expression for validating numbers only
To my knowledge, this matches all the variations on numbers that Java and Java Script will ever throw at you, including "-Infinity", "1e-24" and "Na N".It also matches numbers you might type, such as "-.5".With the above, I am getting the error "UPRN must be numeric" whether its a string or int What's going on here?but these are accepting the characters : ^,$,(,), etc I thought that both the regexes above would do the trick and I'm not sure why its accepting those characters.Above regex will recognize both as correct numbers. (period) itself without any digits is not a correct number.That's why we need two regex parts there (separated with a "|"). I think that this one is the simplest one and it accepts European and USA way of writing numbers e.g.It bypasses all the JS folklore, like tipeof(Na N) = number, parseint('1 Kg') = 1, booleans coerced into numbers, and the like.
But if you only want to match whole numbers like 2, 3, 333, 545 etc.Lookbehind has limitations, like the phrase cannot include quantifiers. You can use alternation, but only if all alternatives have the same length.