Understanding Regex Patterns

Understanding Regex Patterns

A regex pattern screens each character in a form input against a set of rules. Before the pattern is saved, Zoho Forms checks it for structural validity, ensuring text elements like letters, numbers, or symbols appear in the correct sequence.

Regex symbols and how to use them

Understanding what each symbol does helps you read patterns and spot why a particular input might be accepted or blocked.

Boundary anchors
^ marks the start of the input and $ marks the end. Together they force the pattern to match the entire input.

Without anchors, a pattern like \d{3} would match any three digits it finds, including inside a longer string like abc123xyz. Anchoring it as ^\d{3}$ means the input must be exactly three digits and nothing else.

Examples: 
123 -> matches ^\d{3}$ — exactly three digits
1234 -> blocked — four digits overflow the boundary
abc123 -> blocked — letters before the digits violate the start anchor

Character sets
[...] matches exactly one character from the list or range inside the brackets. [A-Za-z] matches any single letter; [0-9] matches any single digit. The set defines what is allowed and anything outside it is blocked.
A common mistake is forgetting to include characters that valid input actually contains. A space, a hyphen, or an apostrophe all need to be declared explicitly if they should be allowed.

Examples:
John -> matches ^[A-Za-z]+$ — all letters
John Doe -> blocked — space is not declared in the set
J0hn -> blocked — digit is not declared in the set

Quantifiers
Quantifiers control how many times the preceding element must appear. {min,max} sets a range, {n} sets an exact count, + means one or more, and * means zero or more. They apply to the character, set, or group immediately before them.
If input is shorter or longer than what the quantifier allows, the pattern does not match.

Examples:
90210 -> matches ^[0-9]{5}$ — exactly five digits
9021 -> blocked — only four digits, one short
902104 -> blocked — six digits, one excess

The escape character
A backslash \ removes the special meaning from the character that follows it, so the parser treats it as plain text instead of syntax. This matters most for characters like ., (, {, and +, which all have roles in regex syntax.

An unescaped dot . matches 'any character' at all. If you need to match a literal period in a decimal number or a file extension, for example, it must be written as \.

Examples:
19.99 -> matches ^\d+\.\d{2}$ — literal period required
19a99 -> matches ^\d+.\d{2}$

Patterns that are not accepted

When you save a regex pattern in Zoho Forms, the builder validates it first. We have listed some patterns that contain structural problems the parser cannot resolve, and patterns that risk affecting form performance.

Unclosed structures
Every opening bracket [, brace {, or parenthesis ( must have a matching closing counterpart.

a{2
Attempts to match the character a exactly twice. The opening { starts a repetition block but there is no closing }, so the parser cannot determine where the block ends. Write it as a{2}.

[abc
Attempts to match one of the characters a, b, or c. The opening [ starts a character class but there is no closing ]. Write it as [abc].

[abc\
Same unclosed character class, with the additional problem that the pattern ends on a backslash. The backslash signals the start of an escape sequence but there is no character after it to complete it.

\p{L
Attempts to match any Unicode letter using the \p{L} category escape. The opening { is present but the closing } is missing. Write it as \p{L}.

\p (end of pattern)
The \p escape requires a category name in braces immediately after it, such as \p{L} or \p{N}. A lone \p at the end of the pattern has nothing to complete it.

\x{1
Attempts to match a character by its hexadecimal code point. The opening { is present but the closing } is missing. A complete example would be \x{0041}.

(?< (pattern ends there)
Starts a look-behind group but the pattern ends immediately after <. A look-behind must be either (?<=...) for a positive look-behind or (?<!...) for a negative one. The parser cannot identify the group type from (?< alone.

Invalid repetition ranges
The content inside {} must be digits in a recognised format, an exact count like {3}, a bounded range like {2,5}, or an unbounded minimum like {2,}. Anything else is not a valid repetition instruction.

a{} and a{x}
The braces are present but contain either nothing or a non-digit character. Supply a number, for example a{3} for exactly three repetitions, or a{2,5} for a range.

a{3,1}
The upper bound is lower than the lower bound, which is a contradiction. A range of "at least three but no more than one" cannot match anything. The values need to be in ascending order like a{1,3}.

Incomplete escape sequences
Every escape sequence has a fixed form. The characters or digits that follow the backslash are part of the sequence and must be fully supplied.

\08
An octal escape starting with \0 must be followed by a digit in the range 0 to 7. The digit 8 does not exist in octal, so the sequence is invalid. \07 is a valid octal escape.

\u12
A \u unicode escape always requires exactly four hexadecimal digits. Two digits is not enough. The correct form is \u0012 or any other four-digit combination.

a\ (trailing backslash)
A backslash at the very end of a pattern has nothing after it to form a sequence. To match a literal backslash, escape it as a\\.

Unknown group types
A group opening (? must be followed by a recognised modifier. Only specific characters are valid after the ? and anything outside that set makes the group type unrecognisable.

(?<X...)
After < inside a group, only = for a positive look-behind and ! for a negative look-behind are valid. Any other character makes the group type unknown. Use (?<=...) or (?<!...).

(?X...)
After the opening ?, only : for a non-capturing group, = for a positive lookahead, and ! for a negative lookahead are recognised. Any other character is not a valid modifier.

Misplaced quantifiers and anchors
A quantifier must always follow a character, set, or group. It cannot appear at the start of a pattern or right after another quantifier. Anchors are only valid at the top level of a pattern, in a fixed position.

*a also +a, ?a
A quantifier at the start of a pattern has no preceding element to apply to. Move it after the character or group it should repeat — a*, a+, a?.

a**
Two quantifiers in a row, the second one has nothing new to apply to. One quantifier per element is enough.

a$b
The $ anchor marks the end of the input, so no characters can follow it at the top level. Anything written after $ cannot be matched, making the pattern contradictory.

a^ and ^^a
The ^ anchor is only valid at the very start of the top-level pattern. Once any term has been parsed, a ^ mid-expression has no valid meaning. In ^^a, the first ^ is consumed normally, leaving the second one stranded.

(^a) and (a$)
Anchors inside parentheses are not supported. Even if ^ appears at the start of the group content or $ at the end, they are still inside a nested context. Anchors must stay at the top level of the pattern.

Nested quantifiers
Unlike the cases above, nested quantifiers are not a structural error, the pattern is syntactically valid and the parser can read it. The problem is performance. When a respondent enters input that does not match, the engine has to explore an exponentially growing number of combinations before it can confirm the failure. On a long input string, this can freeze the browser entirely. Zoho Forms detects this category of pattern when you save and blocks it before it can affect your respondents.

(a+)+
A group with a quantifier, containing another quantifier inside it. For valid input like aaa this works fine, but for input that does not match, say aaab, the engine has to explore every possible way the two quantifiers could divide the characters between them. The number of combinations grows rapidly with input length.

(a*)*
The same structure using *. Since * also allows zero repetitions, the engine has even more combinations to try on a non-matching input. This is one of the most common forms of the problem.

([a-z]+)*
A character class with a quantifier, wrapped in a group with another quantifier. The nesting does not have to involve a single character, any repeating element inside a repeating group creates the same risk.

To avoid this, use a bounded range like {n} or {min,max} on the inner element rather than stacking open-ended quantifiers on top of each other.


        Create. Review. Publish.

        Write, edit, collaborate on, and publish documents to different content management platforms.

        Get Started Now


          Access your files securely from anywhere

            Zoho CRM Training Programs

            Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

            Zoho CRM Training
              Redefine the way you work
              with Zoho Workplace

                Zoho DataPrep Personalized Demo

                If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

                Zoho CRM Training

                  Create, share, and deliver

                  beautiful slides from anywhere.

                  Get Started Now


                    Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                    BOOK A SESSION







                                Quick LinksWorkflow AutomationData Collection
                                Web FormsEnterpriseOnline Data Collection Tool
                                Embeddable FormsBankingBegin Data Collection
                                Interactive FormsWorkplaceData Collection App
                                CRM FormsCustomer ServiceAccessible Forms
                                Digital FormsMarketingForms for Small Business
                                HTML FormsEducationForms for Enterprise
                                Contact FormsE-commerceForms for any business
                                Lead Generation FormsHealthcareForms for Startups
                                Wordpress FormsCustomer onboardingForms for Small Business
                                No Code FormsConstructionRSVP tool for holidays
                                Free FormsTravelFeatures for Order Forms
                                Prefill FormsNon-Profit

                                Intake FormsLegal
                                Mobile App
                                Form DesignerHR
                                Mobile Forms
                                Card FormsFoodOffline Forms
                                Assign FormsPhotographyMobile Forms Features
                                Translate FormsReal EstateKiosk in Mobile Forms
                                Electronic Forms
                                Drag & drop form builder

                                Notification Emails for FormsAlternativesSecurity & Compliance
                                Holiday FormsGoogle Forms alternative GDPR
                                Form to PDFJotform alternativeHIPAA Forms
                                Email FormsFormstack alternativeEncrypted Forms

                                Wufoo alternativeSecure Forms

                                TypeformWCAG

                                  Zoho FSM Video Tutorials


                                        All-in-one knowledge management and training platform for your employees and customers.

                                                  Create. Review. Publish.

                                                  Write, edit, collaborate on, and publish documents to different content management platforms.

                                                  Get Started Now




                                                                    You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                                        Manage your brands on social media


                                                                          • Desk Community Learning Series


                                                                          • Digest


                                                                          • Functions


                                                                          • Meetups


                                                                          • Kbase


                                                                          • Resources


                                                                          • Glossary


                                                                          • Desk Marketplace


                                                                          • MVP Corner


                                                                          • Word of the Day


                                                                          • Ask the Experts


                                                                            Zoho Sheet Resources

                                                                             

                                                                                Zoho Forms Resources


                                                                                  Secure your business
                                                                                  communication with Zoho Mail


                                                                                  Mail on the move with
                                                                                  Zoho Mail mobile application

                                                                                    Stay on top of your schedule
                                                                                    at all times


                                                                                    Carry your calendar with you
                                                                                    Anytime, anywhere




                                                                                          Zoho Sign Resources

                                                                                            Sign, Paperless!

                                                                                            Sign and send business documents on the go!

                                                                                            Get Started Now




                                                                                                    Zoho TeamInbox Resources





                                                                                                              Zoho DataPrep Demo

                                                                                                              Get a personalized demo or POC

                                                                                                              REGISTER NOW


                                                                                                                Design. Discuss. Deliver.

                                                                                                                Create visually engaging stories with Zoho Show.

                                                                                                                Get Started Now








                                                                                                                                    • Related Articles

                                                                                                                                    • Regex

                                                                                                                                      The Regex (regular expressions) field allows you to collect input that must match a specific pattern. Use this field to enforce strict formatting for specialized data such as national ID, tax identifiers, or custom alphanumeric sequences ensuring ...
                                                                                                                                    • Understanding Spotlight Forms

                                                                                                                                      A Spotlight Form displays all fields on a single scrollable page, but only one field is in focus at a time. As respondents scroll, each field moves into an active state, visually highlighted, and centered, while surrounding fields are dimmed. The ...
                                                                                                                                    • Understanding Card Forms

                                                                                                                                      Assume you meet a new person and want to get along with them, and you say: Hey, what is your name, phone number, address, likes and dislikes, and so on? Being bombarded with questions before they have finished answering the first can frighten the ...
                                                                                                                                    • Understanding your Standard form builder

                                                                                                                                      The form builder is your interface for building and modifying forms in your Zoho Forms account. Once you access your Zoho Forms account, and get started to create a new form, you will land on your form builder screen. Before you begin to build your ...
                                                                                                                                    • Zoho CRM field

                                                                                                                                      The Zoho CRM field is a lookup field that helps you fetch data from a Zoho CRM module and prefill your form fields. Prefilling forms with data simplifies the form filling experience for your respondents and saves time. You can also push form entries ...
                                                                                                                                      Wherever you are is as good as
                                                                                                                                      your workplace

                                                                                                                                        Resources

                                                                                                                                        Videos

                                                                                                                                        Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                        eBooks

                                                                                                                                        Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                        Webinars

                                                                                                                                        Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                        CRM Tips

                                                                                                                                        Make the most of Zoho CRM with these useful tips.



                                                                                                                                          Zoho Show Resources