For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
Zoho Deluge - Some Useful Regular Expressions

Zoho Deluge - Some Useful Regular Expressions

What
A more comprehensive post on some other regex (regular expressions) to format values in Zoho.

How?
The following will remove any non-digits:
copyraw
v_MyString = "<b>Hello World 123</b>";
v_MyFormattedString = v_MyString.replaceAll("[^0-9]","");
// yields 123
  1.  v_MyString = "<b>Hello World 123</b>"
  2.  v_MyFormattedString = v_MyString.replaceAll("[^0-9]","")
  3.  // yields 123 

The following is used in searches to escape special characters with a backslash:
copyraw
v_MyString = "Joe's \"Amazing\" Skill &  Sidekick (1)";
v_FormattedString = v_MyString.replaceAll(("([&'\"\%()])"),"\\$1",true);
// yields Joe\'s \"Amazing\" Skill \& \ Sidekick \(1\)

v_FormattedString = v_MyString.replaceAll("%"),"\u0025",true);
  1.  v_MyString = "Joe's \"Amazing\" Skill &  Sidekick (1)"
  2.  v_FormattedString = v_MyString.replaceAll(("([&'\"\%()])"),"\\$1",true)
  3.  // yields Joe\'s \"Amazing\" Skill \& \ Sidekick \(1\) 
  4.   
  5.  v_FormattedString = v_MyString.replaceAll("%"),"\u0025",true)

The following will strip all HTML/XML tags:
copyraw
v_MyString = "<b style='color:red'>Hello World 123</b>";
v_MyFormattedString = v_MyString.replaceAll("<(.|\n)*?>","");
// yields Hello World 123
  1.  v_MyString = "<b style='color:red'>Hello World 123</b>"
  2.  v_MyFormattedString = v_MyString.replaceAll("<(.|\n)*?>","")
  3.  // yields Hello World 123 

URL safe slug:
copyraw
v_MyString = "Hello World 123";
v_MyFormattedString = v_MyString.toLowerCase().replaceAll(" ","-");
v_MyFormattedString = v_MyFormattedString.replaceAll("[^a-z0-9-]+","");
// yields hello-world-123
  1.  v_MyString = "Hello World 123"
  2.  v_MyFormattedString = v_MyString.toLowerCase().replaceAll(" ","-")
  3.  v_MyFormattedString = v_MyFormattedString.replaceAll("[^a-z0-9-]+","")
  4.  // yields hello-world-123 

Email safe string:
copyraw
v_MyString = "somewhere[]@beyondthesea_1.com";
v_MyFormattedString = v_MyString.toLowerCase().trim();
v_MyFormattedString = v_MyFormattedString.replaceAll("[^a-z0-9@\-.]+","");
// yields This email address is being protected from spambots. You need JavaScript enabled to view it.
  1.  v_MyString = "somewhere[]@beyondthesea_1.com"
  2.  v_MyFormattedString = v_MyString.toLowerCase().trim()
  3.  v_MyFormattedString = v_MyFormattedString.replaceAll("[^a-z0-9@\-.]+","")
  4.  // yields This email address is being protected from spambots. You need JavaScript enabled to view it. 

Replace any duplicates:
copyraw
v_MyString = "Hello World Hello Joe";
v_MyFormattedString = v_MyString.replaceAll("(\b\w+\b)(?=.*\b\1\b)","");
// yields World Hello Joe
  1.  v_MyString = "Hello World Hello Joe"
  2.  v_MyFormattedString = v_MyString.replaceAll("(\b\w+\b)(?=.*\b\1\b)","")
  3.  // yields World Hello Joe 

Remove block comments:
copyraw
v_MyRegEx = "(\/\*([^*]|(\*+[^*\/]))*\*+\/)";
v_MyString = "String to output: /* this is a comment */";
v_MyFormattedString = v_MyString.replaceAll(v_MyRegEx,"");
// yields String to output:
  1.  v_MyRegEx = "(\/\*([^*]|(\*+[^*\/]))*\*+\/)"
  2.  v_MyString = "String to output: /* this is a comment */"
  3.  v_MyFormattedString = v_MyString.replaceAll(v_MyRegEx,"")
  4.  // yields String to output: 

Zoho Deluge Validation Checking by Regular Expression:

So I could do it the long way in Zoho Deluge. We match a pattern and replace everything out that conforms to the criteria so a true response will be an empty string:
copyraw
v_MyRegEx = "^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,}$";
v_MyString = "This email address is being protected from spambots. You need JavaScript enabled to view it.";
v_MyFormattedString = v_MyString.replaceAll(v_MyRegEx,"");
b_Ok = if( v_MyFormattedString == "", true, false);
// yields true

v_MyString = "somewhere[]@beyondthesea_1.com";
v_MyFormattedString = v_MyString.replaceAll(v_MyRegEx,"");
b_Ok = if( v_MyFormattedString == "", true, false);
// yields false
  1.  v_MyRegEx = "^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,}$"
  2.  v_MyString = "This email address is being protected from spambots. You need JavaScript enabled to view it."
  3.  v_MyFormattedString = v_MyString.replaceAll(v_MyRegEx,"")
  4.  b_Ok = if( v_MyFormattedString == "", true, false)
  5.  // yields true 
  6.   
  7.  v_MyString = "somewhere[]@beyondthesea_1.com"
  8.  v_MyFormattedString = v_MyString.replaceAll(v_MyRegEx,"")
  9.  b_Ok = if( v_MyFormattedString == "", true, false)
  10.  // yields false 

Yay Zoho has "matches". So this is the regex way to do it:
copyraw
v_MyRegEx = "^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,}$";
v_MyString = "This email address is being protected from spambots. You need JavaScript enabled to view it.";
b_Ok = if( v_MyString.matches( v_MyRegEx  ), true, false);
// yields true
  1.  v_MyRegEx = "^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,}$"
  2.  v_MyString = "This email address is being protected from spambots. You need JavaScript enabled to view it."
  3.  b_Ok = if( v_MyString.matches( v_MyRegEx  ), true, false)
  4.  // yields true 

Some other validation checks:
copyraw
// validate UK postcode
v_MyRegEx = "^((([A-PR-UWYZ])([0-9][0-9A-HJKS-UW]?))|(([A-PR-UWYZ][A-HK-Y])([0-9][0-9ABEHMNPRV-Y]?))\s{0,2}(([0-9])([ABD-HJLNP-UW-Z])([ABD-HJLNP-UW-Z])))|(((GI)(R))\s{0,2}((0)(A)(A)))$";
  1.  // validate UK postcode 
  2.  v_MyRegEx = "^((([A-PR-UWYZ])([0-9][0-9A-HJKS-UW]?))|(([A-PR-UWYZ][A-HK-Y])([0-9][0-9ABEHMNPRV-Y]?))\s{0,2}(([0-9])([ABD-HJLNP-UW-Z])([ABD-HJLNP-UW-Z])))|(((GI)(R))\s{0,2}((0)(A)(A)))$"

Some XML bits:
copyraw
v_MyRegEx = "<!\[CDATA\[([^\]]*)\]\]>";
v_MyString = "<tag1><![CDATA[my_real_textual_data]]></tag1>";
v_FormattedString = v_MyString.replaceAll(v_MyRegEx,"$1",false);
// yields <tag1>my_real_textual_data</tag1>
  1.  v_MyRegEx = "<!\[CDATA\[([^\]]*)\]\]>"
  2.  v_MyString = "<tag1><![CDATA[my_real_textual_data]]></tag1>"
  3.  v_FormattedString = v_MyString.replaceAll(v_MyRegEx,"$1",false)
  4.  // yields <tag1>my_real_textual_data</tag1> 


Additional
Since writing this article I found a Zoho page with some other pretty useful regular expressions at https://zoholic.blogspot.com/2015/04/some-usefull-regex-in-zoho.html:

Convert a string of characters to a list:
copyraw
v_MyString = "12345";
l_StringValues = v_MyString.replaceAll("(?)",",",false).removeFirstOccurence(",").removeLastOccurence(",").toList();
// yields list of [1,2,3,4,5]

// NB: "1mySep2mySep3mySep4mySep5".toList("mySep");
// yields list of [1,2,3,4,5]
  1.  v_MyString = "12345"
  2.  l_StringValues = v_MyString.replaceAll("(?)",",",false).removeFirstOccurence(",").removeLastOccurence(",").toList()
  3.  // yields list of [1,2,3,4,5] 
  4.   
  5.  // NB: "1mySep2mySep3mySep4mySep5".toList("mySep")
  6.  // yields list of [1,2,3,4,5] 

Replace any multiple spaces with a single space:
copyraw
v_MyString = "Hello   World!";
v_FormattedString = v_MyString.replaceAll("[ ]+"," ",false); 
// yields Hello World!
  1.  v_MyString = "Hello   World!"
  2.  v_FormattedString = v_MyString.replaceAll("[ ]+"," ",false)
  3.  // yields Hello World! 

Remove consecutive duplicate words:
copyraw
// replace consecutive duplicates
v_MyString = "Hello Hello Joe";
v_FormattedString = v_MyString.replaceAll(("([A-Za-z]+) \1"),"$1",false);
// yields Hello Joe

// NB: v_MyString = "Hello World Hello Joe"
// yields Hello World Hello Joe
  1.  // replace consecutive duplicates 
  2.  v_MyString = "Hello Hello Joe"
  3.  v_FormattedString = v_MyString.replaceAll(("([A-Za-z]+) \1"),"$1",false)
  4.  // yields Hello Joe 
  5.   
  6.  // NB: v_MyString = "Hello World Hello Joe" 
  7.  // yields Hello World Hello Joe 

Escape/Backslash some special characters:
copyraw
v_MyString = "Joe's \"Amazing\" Skill & <His> Grunt";
v_FormattedString = v_MyString.replaceAll(("([&'\"<>])"),"\\$1",false);
// yields Joe\'s \"Amazing\" Skill \& \<His\> Grunt
  1.  v_MyString = "Joe's \"Amazing\" Skill & <His> Grunt"
  2.  v_FormattedString = v_MyString.replaceAll(("([&'\"<>])"),"\\$1",false)
  3.  // yields Joe\'s \"Amazing\" Skill \& \<His\> Grunt 

Replace new lines in returned JSON (invalid in Zoho):
copyraw
v_MyString = "{"MyKey":"MyValue
"}";

// the long way (and cos the regex for this isn't working)
v_FormattedString = v_MyString.replaceAll("\r","",false);  // carriage returns
v_FormattedString = v_MyString.replaceAll("\n","",false);  // line feeds
v_FormattedString = v_MyString.replaceAll("\f","",false);  // form feeds

// a regex that should work but doesn't
v_FormattedString = v_MyString.replaceAll(("([\n\r])"),"",false);
  1.  v_MyString = "{"MyKey":"MyValue 
  2.  "}"
  3.   
  4.  // the long way (and cos the regex for this isn't working) 
  5.  v_FormattedString = v_MyString.replaceAll("\r","",false);  // carriage returns 
  6.  v_FormattedString = v_MyString.replaceAll("\n","",false);  // line feeds 
  7.  v_FormattedString = v_MyString.replaceAll("\f","",false);  // form feeds 
  8.   
  9.  // a regex that should work but doesn't 
  10.  v_FormattedString = v_MyString.replaceAll(("([\n\r])"),"",false)

Split a string by a word:
copyraw
v_MyString = "PoshDavid Beckham";
v_FormattedString = v_MyString.replaceAll("\b(Posh)([^ ]*)","$1 and $2",false);
// yields Posh and David Beckham
  1.  v_MyString = "PoshDavid Beckham"
  2.  v_FormattedString = v_MyString.replaceAll("\b(Posh)([]*)","$1 and $2",false)
  3.  // yields Posh and David Beckham 

UK/US Decimal Separator and Commas:
copyraw
v_MyString = 1234.567;
v_FormattedString = (v_MyString.round(2)).toString().replaceAll(("(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)"),",");
// yields 1,234.57
  1.  v_MyString = 1234.567
  2.  v_FormattedString = (v_MyString.round(2)).toString().replaceAll(("(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)"),",")
  3.  // yields 1,234.57 

European Decimal Separator and Commas:
copyraw
v_MyString = 1234.567;
v_FormattedString = (v_MyString.round(2)).toString().replaceAll("\.",",").replaceAll(("(?<!,\d)(?<=\d)(?=(?:\d\d\d)+\b)"),".");
// yields 1.234,57
  1.  v_MyString = 1234.567
  2.  v_FormattedString = (v_MyString.round(2)).toString().replaceAll("\.",",").replaceAll(("(?<!,\d)(?<=\d)(?=(?:\d\d\d)+\b)"),".")
  3.  // yields 1.234,57 

Extract URL from a link:
copyraw
v_MyString = "<a href=\"https://www.google.com?searchword=Joe\">Link</a>";
v_FormattedString = v_MyString.replaceAll("^.*href\s*=\s*\"([^\"]*)\".*$","$1");
// yields https://www.google.com?searchword=Joe
  1.  v_MyString = "<a href=\"https://www.google.com?searchword=Joe\">Link</a>"
  2.  v_FormattedString = v_MyString.replaceAll("^.*href\s*=\s*\"([^\"]*)\".*$","$1")
  3.  // yields https://www.google.com?searchword=Joe 

Get first 3 words:
copyraw
v_MyString = "I am Joe the Awesomest";
v_FormattedString = v_MyString.replaceAll("^((?:\S+\s+){2}\S+).*","$1",false);
// yields I am Joe
  1.  v_MyString = "I am Joe the Awesomest"
  2.  v_FormattedString = v_MyString.replaceAll("^((?:\S+\s+){2}\S+).*","$1",false)
  3.  // yields I am Joe 

Not a regular expression but something I use to pad months and dates in a date format:
copyraw
v_MyString = 2;  // February
v_FormattedString = leftpad(toString(v_MyString), 2).replaceAll(" ", "0");
// yields "02"
  1.  v_MyString = 2;  // February 
  2.  v_FormattedString = leftpad(toString(v_MyString), 2).replaceAll(" ", "0")
  3.  // yields "02" 
Category: Zoho Deluge :: Article: 238

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

Donate & Support

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

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com