I currently use this regex:
(\d+)
the problem that i can get 2 strings:
“2112343 and alot of 4.99”
OR
“4.99 and alot of 2112343 “
I get this from both:
[2112343, 4, 99]
I need to get only the 2112343…
How can i achieve this?
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.
Using lookaround, you can restrict your capturing to only digits which are not surrounded by other digits or decimal points:
Alternatively, if you want to only match stand-alone numbers (e.g. if you don’t want to match the 123 in
abc123def):