retrieve number from string

I want to extract/ retrieve number from the string eg :-”open page number 10”. I want to get number 10 as a return value.
2 answers

How many numbers will be in the string? Will they always be written with digits, or could they be words as well. e.g. “ten”.

Assuming the number will be be digits, and will only occur once, then one approach would be to use a regular expression to extract them using the replaceAll function. For example, replace any character that isn’t a digit with nothing.

replaceAll('open page number 10', '(\D)', '')

That should just give you a string with the digits in that you can use the parseInteger function on to return an Integer with the value of 10.

Hope this helps


Hi Shubham,


You can achieve this with string function calls and with a regular expression: