I have a string and want to wrap non-numbers with double quotes (if they don't have them already). What is the best way to detect a non-number with a regex?
These are numbers: 123.43, 13827. These are non numbers: Hello, 2011-02-45, 20a, A23.
Here is the regex I currently have but does not handle the case where a non-number starts with a digit (so 2011-02-45 is not picked up).
str = str.replace(/(['"])?([a-zA-Z0-9_\-]+)(['"])?:/g, '"$2":');
str = str.replace(/:(['"])?([a-zA-Z_]+[a-zA-Z0-9_]*)(['"])?/g, ':"$2"');