Zoho Deluge - Regex to Strip all non-numeric characters

A quick post on how I managed to build a regex to extract all non-numeric characters (all non-digits) from a string.

I only want the digits/numbers from a string:
v_PaymentTerms = "Credit Note - 30 Days";

// we want the 30 from the above string

I'm aware of the getAlphaNumeric() function in Zoho and I can remove the letters with removeAllAlpha():
v_PaymentTermsAlphaNum = v_PaymentTerms.getAlphaNumeric();
// yields CreditNote30Days

vPaymentTermsNum = v_PaymentTermsAlphaNum.removeAllAlpha()
// yields 30

But just to demo a regex and a one liner, here's a typical regular expression (match all characters not from 0 to 9) in a Zoho Deluge script:
v_PaymentTermsNumber = v_PaymentTerms.replaceAll("[^0-9]","");
// yields 30

And if working with money/currencies, a one liner to maintain the decimal point
v_SalesAmount = "Total : £ 5.00";
v_SalesAmount = v_SalesAmount.replaceAll("[^0-9.]","");
// yields 5.00

Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.