Hi I'm trying to remove the letters and special characters from javascript.
Example:
var id = "Parameter[0].Category"
I only need the "0" from this. Thank you
Hi I'm trying to remove the letters and special characters from javascript.
Example:
var id = "Parameter[0].Category"
I only need the "0" from this. Thank you
Try this
var numbers = id.match(/\d+/)[0];
console.log(numbers);
In general this is called filtering using regular expressions.
If you want to filter out letters and special characters you can use regular expression in JS, like this:
id = id.replace(/\D/g, "")
You replace every (g
option) character in your string that is not a digit \D
with blank ""