In Javascript, what is the best way to remove non numeric characters from the beginning of a string?
-_1234d5fr
should ideally turn into
1234d5fr
str = str.replace(/^\D+/, '');
\D
stands for non-digit characters^
matches the position before the first character in the string+
is "one or more of"How about...
str = str.replace(/^[^0-9]+/, '');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With