Page 1 of 1

Copy the last 2-3 digits in an sms.

Posted: 09 Mar 2016 23:48
by Adib
I want to extract 2 string of numbers from an sms, for example.

"0123456789 JANE 50"

"0123456789" is called the MSISDN

"50" is called AMOUNT, may vary from 1-100.

I learnt how to extract MSISDN but i can't figure out how to extract AMOUNT.

Any help is greatly appreciated, Martin. Thanks!

Re: Copy the last 2-3 digits in an sms.

Posted: 10 Mar 2016 18:52
by Martin
You can use a regex to extract the 50:

Code: Select all

sms_text = "0123456789 JANE 50";
groups = newList();
matches(sms_text, '.*\\s(\\d+).*', groups);
amount = groups[1];
Regards,
Martin