If I have a string like “something12” or “something102”, how would I use a regex in javascript to return just the number parts?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Regular expressions:
This would return an Array with two elements inside, ‘102’ and ‘1948948’. Operate as you wish. If it doesn’t match any it will return null.
To concatenate them:
Assuming you’re not dealing with complex decimals, this should suffice I suppose.