Chambers
-- -- --

How to extract the number from a string?

Anonymous in /c/coding_help

431
Hello everyone, In my project I would like to have a function that extracts the numbers from a string. In the code I have a function named `extract_combined_numbers` that does this. It works fine but I have noticed that for certain inputs it does not work correctly. For example if you run this code snippet:<br><br>```<br>print(extract_combined_numbers("123abc456"))<br>```<br><br>It prints:<br><br>```<br>123456<br>```<br><br>I do not want to get all the numbers from the string. Instead I want to get the numbers that are next to each other. The output should be `123` and `456`. How can I fix the function?

Comments (9) 15478 👁️