Skip to main content

How to retrieve the only number from a string?

Suppose there is a pop-up like below which has a combination of text and Numbers and if we want to retrieve only Numbers

Then we can use the below code to fetch only Numbers

Store the content into a variable and apply to replace(/[^0-9]/g, "") to the string and it will fetch only Numbers present in the string

Code Snippet

Logs from DS3


Last updated: June 26, 2023

If you have any feedback on this topic, please contact us at documentation@appvance.ai