When you convert to a string the '-' loses context. You would need ^[-+]?\d*$ to allow the negative sign. This doesn't work for decimals btw. Not sure if you want those.
I did mention it doesn't work for decimals. Regex is useful. Use this site for testing and see what you can find from google to account for decimals. regexr.com/
Hint: '.' Is a special character
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
When you convert to a string the '-' loses context. You would need ^[-+]?\d*$ to allow the negative sign. This doesn't work for decimals btw. Not sure if you want those.
still not working
gives an unexpected error.
Help
I did mention it doesn't work for decimals. Regex is useful. Use this site for testing and see what you can find from google to account for decimals.
regexr.com/
Hint: '.' Is a special character