retrieve number from string

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

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

answered
0

Hi Shubham,

 

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

https://docs.mendix.com/refguide/string-function-calls/

https://docs.mendix.com/refguide/regular-expressions/ 

answered