Strange Regex Issue with [^0-9]
OK - no laughing at my Regex (it drives me mad!!) I'm trying to only allow digits and replace spaces with commas - this is the line I had
- var fixedInput = currentInput.replace(/[A-Za-z!@#$%^&*()]/g,"").replace(/[^0-9]/g, ",").replace(/,+/g,",").replace(/^, /,"");
There was a strange thing happening - when this output on load the 0 was removed from the digit line - like this:
- var fixedInput = currentInput.replace(/[A-Za-z!@#$%^&*()]/g,"").replace(/[^-9]/g, ",").replace(/,+/g,",").replace(/^, /,"");
I managed to get around it my replacing
[^-9] it with
[^\d]
But I'd like to know why it happened in the first place - is it my regex?
Strangely it was working perfectly on dev site, but not on the other on the same server - sites identical??