Regex in Zoho Mail custom filters is not supported - but it works!

Regex in Zoho Mail custom filters is not supported - but it works!

I recently asked Zoho for help using regex in Zoho Mail custom filters and was told it was NOT supported.
This was surprising (and frustrating) as regex in Zoho Mail certainly works, although it does have some quirks*

To encourage others, here are 3 regex examples I created in mail custom filters that have worked fine for me.

Spoiler: I'm not a coder so these examples took me a lot of searching (thanks to others on this site) and tinkering to get the job done — if anyone has improvements on these regex examples, I'm very happy for you to offer them.

Regex examples

1) Purpose: to find all Jpeg, Jpg and Png image urls in email content
regex = "(https?:\/\/[^\s'\"]+?\.(?:jpg|jpeg|png))";

2) Purpose: to find all image urls in email content
regex = '<img[^>]*src="(https?:[^\s,">]*)"';

3) Purpose: to remove unwanted characters in email content, leaving only the urls matched in examples 1 and 2
regex = "\A[\s\S]+?\|\||\|\|[\s\S]+?\||\|\|[\s\S]+?\Z";

Regex explanation and script examples:

1) regex = "(https?:\/\/[^\s'\"]+?\.(?:jpg|jpeg|png))";

(...)                        outer brackets allow match to be captured by variable $1
https?                  ? makes the previous char optional, so matches http or https
:                            literal colon
\/\/                      '\' is required to escape '/' so \/\/, matches '//'
[^...]                      ^ = don't match chars in square brackets
\s                          = white space
'                             = single quote
\"                           = escaped double quote — matches double quote
                               (if i had used single quotes, instead of double, around the whole regex
                                I wouldn't have needed to escape the double quote here)
                              So, [^\s'\"] means match any char EXCEPT white space, single or double quotes
+                           + = match one or more of the chars in square brackets
?                            ? = match the LEAST number of chars (lazy match)
\.                           = escaped dot matches an actual dot (without escape, the dot would match any char except newline)
(?:...)                      ?: = this bracketed group will not be captured by any variable
jpg|jpeg|png         the pipe means 'OR' so this group matches jpg OR jpeg OR png

Script Example
foundUrls = mailContent.replaceall(regex,"||$1||");

Here the $1 variable captures the regex match between (...) so, "||$1||" means 'replace each match with a double pipe and the match, and a double pipe. i.e. place a double pipe around each matched URL.


2) regex = '<img[^>]*src="(https?:[^\s,">]*)"';

'....'                              using single quotes means it's not necessary to escape the double quotes inside the regex
<img                          matches liters <img 
[^>]                            match any character EXCEPT >
*                                 match the chars in the square brackets zero or multiple times
src="                          match literal src="
(...)                              the match inside the brackets is saved to variable $1
https?                        match http or https (? means previous char is optional)
:                                  literal colon
[^\s,">]*                     match any character EXCEPT white space, double quote, chevron — zero or multiple times
"                                  the match must finish with a double quote

NB: the captured variable $1 will only contain the URL from http up to, but not including the final double quote

Script Example

foundUrls = MailContent.replaceAll(regex,"||$1||");

Here, the 'long' URL (<img.. src..."http...) is replaced by the 'short' URL (http....) and surrounded by double pipes


3) regex = "\A[\s\S]+?\|\||\|\|[\s\S]+?\||\|\|[\s\S]+?\Z";

The regex has three options for a match, each separated by a pipe meaning 'OR'

First option:
 \A                  = Start Of File (i.e search from the beginning of the file)
 [\s\S]             matches any white space (\s) and any non-white space (\S)
 +                     + = match one or more of the chars in square brackets
?                       ? = match the LEAST number of characters necessary (lazy match)            
 \|\|                  '\' escapes the pipes so matches '||' (without escape the pipes would be read as 'OR')
 |                       unescaped pipe = OR (i.e. match either first OR second parts of the regex)
 
Second option:
 \|\|                  escaped pipes, so matches '||' 
[\s\S]+?           match any space or non-space one or more times, but use the LEAST chars necessary
\|                      escaped pipe, so matches '|' (NB: when this group is deleted it will leave one pipe between URLs) 
|                        unescaped pipe = 'OR' (ie match second OR third parts of the regex)

Third option
\|\|                    escaped pipes, matches '||' 
[\s\S]+?            match any space or non-space one or more times, but use the LEAST chars necessary
\Z                     = End Of File (i.e. search to the end of the file)

Script example

 cleanUrls = foundUrls.replaceAll(regex,"");

Thus
Option 1: 'StartOfFile up to and including '||' gets deleted.
Option 2: '||' to '|' inclusive gets deleted (leaving one pipe between URLs)
Option 3: '||' to EndOfFile gets deleted

Replacing the single pipes with commas to form a list of URLs is accomplished with:
urls = cleanUrls.toList("|");

NB These scripts use pipes to bracket and separate URLS It's therefore prudent, BEFORE applying the scripts, to remove any existing pipes from the selected text:

regex = '\|';
cleanMailContent = mailContent.replaceAll(regex,"");

* Quirks of Zoho Mail Deluge 

While the scripting language is similar to JavaScript it is not identical and some features of Regex do not work.
In particular, I've not had success using 'lookahead' or 'lookbehind' operations in Zoho Mail custom filters.



    • Sticky Posts

    • Pocket from Mozilla is closing shop. Don’t lose your favorites . Move them to Zoho Mail Bookmarks now! 📥🔖

      The end of Pocket shouldn't mean the end of your important links and content. Easily import them into Zoho Mail's Bookmarks and continue right where you left off. You can bring over your entire Saves, Collections, and tags just the way they are. Bookmarks
    • Zoho Mail POP & IMAP Server Details

      Hello all! We have been receiving a number of requests regarding the errors while configuring or using Zoho Mail account in POP/ IMAP clients. The server details vary based on your account type and the Datacenter in which your account is setup. Ensure
    • Workplace - Zoholics Europe Customer Awards

      Dear Zoho Mail Community! 📣 We're excited to announce that at this year's Zoholics events across Europe, we're holding customer awards for the first time ever! Workplace - Zoholics Europe Customer Awards This is your chance to shout about the amazing
    • Important update on Group Management | Zoho Mail

      Dear Zoho Mail Community, This post is to inform you all of the following updates on the Group Management in Zoho Mail. Group Member Addition: If a group member is added to an organization group in a Zoho Application, the member will be automatically
    • Mastering email etiquette and best practices to follow in Zoho Mail

      Hello Zoho Mail Community, We’re thrilled to invite you all to our upcoming webinar: Mastering email etiquette and best practices to follow in Zoho Mail. Join our live webinar for expert etiquette tips to enhance your professionalism and elevate your

    Nederlandse Hulpbronnen


      • Recent Topics

      • Cannot reorder fields in Page Layout in Expenses and Purchase Requests

        It is very inconvenient that the custom fields in Page Layout cannot be re-ordered. The only way is to remove the fields and re-create them; however, it is impractical. This would affect the reports and dashboards we are having. Not able to re-order the
      • bouncing emails

        My recurring invoices have bounced back
      • Massive Zoho Books failure

        We have not received any communication or notification from Zoho, but we have detected that Zoho Books is not working for all our users. We cannot access or use Zoho Books. This is critical. We are trying to contact Zoho on the Spain telephone number,
      • Probable Scam / Phising attempt from email pretending to be Zoho

        I think this is a scam email right? It says "zohCworkplace.com". I'm on the Mail Free plan The link in the CTA button seems to go to a redirect. Just wanted to bring it up to the security team.
      • Email Address Search in "To" Field Search is broken, Zoho refuses to fix it

        Typing a part of the email address string other than the beginning of the string does NOT work, I kindly urge Zoho to fix this. Let's say you remember writing an email so someone called "smith" from company "corp.com", but can't remember their first name,
      • Enrich your contact and company details automatically using the Data Enrichment topping

        Greetings, I hope you're all doing well. We're happy to announce the latest topping we've added to Bigin: The Data Enrichment topping, powered by WebAmigo. This topping helps you automatically enhance your contact and company records in Bigin. By leveraging
      • Emails not being received by @hotmail.com, @outlook.com and a few others

        When I try to send emails from zoho mail to people with email addresses ending @outlook.com and @hotmail.com (and a few others), I get a 'delayed' automatic email and then a few hours later, an 'undelivered' automatic email. This has started a few months
      • scroll bar for far left of screen

        I am unable to even see the scroll bar to the right of "inbox" etc on the left; it is stuck at "streams" and I can't get to inbox or anything else. It would help if it could be made a lighter color as the black or dark grey can't bee seen.
      • OUt of office every friday

        Hi, I tryed to configure my out of office, because i'm not working or emailing on fridays. But when i select only friday as unavailable day, the out of office still sets for the whole week. What am I doing wrong?
      • Signature line

        How do I set signature line in email
      • Zoho email

        I cannot send email to mail.ru
      • Please, make writer into a content creation tool

        I'm tired of relying on Google Docs. I'm actually considering moving to ClickUp, but if Writer were a good content creation tool instead of just a word processor, I would finally be able to move all my development within the Zoho ecosystem, rather than
      • Something wrong with client script??

        Someone have the same feeling? Client script behavior become very strange..
      • 【参加無料】東京 Zoho ユーザ交流会 NEXUS ー CRMで始めるマーケティング事例 / AI活用法(Zia Agents)

        ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 3月27日(金)に東京、新橋で東京 Zoho ユーザー交流会 NEXUS を開催します! 昨年度までより、さらにパワーアップして戻ってきました! ユーザー活用事例は、2人のユーザーさんからお話しいただきます。Zoho サービスの活用の幅を広げたい方や、他のユーザーの利用法を気軽に知りたい方など、多くの方にとって学びのあるセッションになること間違いなしです✨ また今年は、これまで以上に、AI機能にも焦点を当てて行く予定です。 初回として、Zoho社員からZoho
      • Issue Exporting Data – CSRF Token Invalid Error

        Dear Zoho Team, We are experiencing an issue when exporting data from our Analytics workspace. Whenever we attempt to export data from our analytical pool, the system displays the following alert message: Alert Message: The CSRF token is invalid. It could
      • Zoho Mail 505 error I can not send email

        Hi, I’m having issues sending emails from my custom domain email address. When I send emails to Outlook addresses, I receive an “Undeliverable 505” error. However, emails send and receive correctly when I use Gmail. This is important for my business,
      • Multiple MFA Methods

        With SMS-based MFA methods being discontinued, there is now no way to have mutliple MFA methods. I'd like to add my zoho account on two seperate phones using the Google Authenticator app. In the https://accounts.zoho.com/home#multiTFA/modes you can only
      • Reuse Standalone Function

        I noticed that there's a missing information in documentation to reuse a standalone function and it is because the parameters require an argument. Here is my code and it is working. response = invokeurl [ url: "https://people.zoho.com/api/v3/function/sample/execute"
      • Domain renewals

        Need to know how hoe to renew the domain
      • MX shopify problem

        hello, i added all MX values in my shopify DNS - it shows those values on the shopify panel + your toolkit. I tried to send some email and it works, however on my gmail it says they cant verify this email. When i try to answer into my domain's email -
      • Best Way to Manage Email Notifications While Running a Strategy Website

        I am currently managing a content-based website, and I use Zoho Mail for handling contact forms, user queries, and collaboration emails. One challenge I am facing is organizing incoming emails efficiently, especially when messages come from different
      • What is the maximum email domains ?

        I help manage about 20 associations and I'm looking for a way to centralize them in one place. Does Zoho Mail pro or enterprise support 20-30 domains for 3-5 users each?
      • Add to Workdrive filter

        I'm trying to create a filter that will upload attachments in emails and the e-mail body to a folder in workdrive. I am able to do one or the other (attachment, or e-mail content), but not both. I first tried it using the "Email (EML) + attachment" option.
      • Forgot my admin Panel Id and password

        Sir, I have an account , where a domain mycityestate.in is added for Zoho email , now it is hard for me to manage email because i have forgotten the Email account and password registered with Admin Panel of Zoho. Just need email name which is registered
      • How can I import OLM to iCloud Mail easily?

        Import OLM files to iCloud Mail can be simple if you follow the right approach. Since iCloud Mail does not support OLM files directly, the most effective method is to use a reliable OLM conversion and migration tool. First, you need to convert the OLM
      • MCP no longer works with Claude

        Anyone else notice Zoho MCP no longer works with Claude? I'm unable to turn this on in the claude chat. When I try to toggle it on, it just does nothing at all. I've tried in incognito, new browsers, etc. - nothing seems to work.
      • Image Compression Options

        Much better if we have level of options to compress the image [20%, 40%...] We are dealing with service reports daily that has before and after photos (image field)- the file size too large and one thing, the current limit is 10mb or 15mb for report
      • WhatsApp IM in Zoho Desk always routes to Admin instead of assigned agent

        Hello Zoho Experts, I connected WhatsApp IM to my Zoho Desk account. I only assigned my Customer Service (CS) agent to the WhatsApp channel, and I did NOT include Admin in this channel. However, every new WhatsApp conversation automatically gets assigned
      • Zoho CRM || Unable to Bulk Assignment of Territories for Contacts

        Dear Zoho CRM Support Team, I hope this email finds you well. We recently performed a bulk upload of Contacts into Zoho CRM using the official sample Excel template downloaded from the CRM. The upload itself was completed successfully; however, we encountered
      • Blocklist candidates in Zoho Recruit

        We’re introducing Block Candidate, which helps recruiters to permanently restrict a candidate from applying to current/future job openings. Once the candidate is blocked, they will no longer be able to participate in the recruitment process. This will
      • Pass shipping info to payment gateway Zoho Books to Authorize.net

        For some reason the integration from Zoho books to Authorize.net does not pass the shipping address. Authorize.net is ready to receive it, but zoho books does not send it
      • Knowledgebase SEO

        We have a custom-domain mapped help center that is not restricted via login. I have some questions: a) will a robots.txt file still allow us to control indexing? b) do we have the ability to edit the sitemap? c) do category URLs get indexed by search
      • Projects Home Customization

        Hello! We've been in Zoho One since July of last year, and my team has started providing feedback on what they'd like to do. Their latest wish is that they could have more control over the Projects Home content. For example, they want a card that shows
      • Power Pivot and Data Modeling functionality in Zoho Sheet

        When will MS Excel functionalities like Power Pivot and Data Modeling functionalities be available in Zoho Sheet?
      • Problem with CRM Connection not Refreshing Token

        I've setup a connection with Zoom in the CRM. I'm using this connection to automate some registrations, so my team doesn't have to manually create them in both the CRM and Zoom. Connection works great in my function until the token expires. It does not refresh and I have to manually revoke the connection and connect it again. I've chatted with Zoho about this and after emailing me that it couldn't be done I asked for specifics on why and they responded. "The connection is CRM is not a feature to
      • New Features: Repeat Last Action, Insert Cut/Copied Rows/Columns and Hyperlink

        You might have noticed the constant updates to Zoho Sheet of late. Here are 3 more features that have been added to Zoho Sheet recently: F4 - Repeat Last Action Insert Cut/Copied Rows and Columns Insert Hyperlink Here is a screen cast demonstrating each of these features. Read further below to learn more about these new features. F4 - Repeat Last Action: You can now repeat the last action you made on your spreadsheet by using the keyboard shortcut, F4. It is quite handy and helps you get your work
      • Need help getting my mail on iPhone and Tablet

        I need to access my Zoho mail via the iPhone Mail app. I have entered the login name, password and the incoming and outgoing servers, which my Mail Settings page says are imappro.zoho.com and smtppro.zoho.com. The iPhone keeps saying it cannot authenticate.
      • Cliq iOS can't see shared screen

        Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
      • Add an background image to an email template in CRM

        Hi all, We wants to put an background image behind all our email templates. Is there a way to import this thru html. If i put the option background image in <body style="background-image:...</body> and i look to the preview it shows our background, but
      • Is there a way to show contact emails in the Account?

        I know I can see the emails I have sent and received on a Contact detail view, but I want to be able to see all the emails that have been sent and received between all an Accounts Contacts on the Account Detail view. That way when I see the Account detail
      • Next Page