I need this function to return true if the string contains number, .dot or % sign.
Here are the. examples of values i need it to return true.
- 100
- 100.00
- 10%
isNumeric(value: any) {
return /^-?d+$/.test(value);
}
I need this function to return true if the string contains number, .dot or % sign.
Here are the. examples of values i need it to return true.
isNumeric(value: any) {
return /^-?d+$/.test(value);
}
2
Answers
d|.|%
would do?You can test the regex on sites such as regex101
You could use the following regex:
-?
– optional minus sign