---
sourceDocument: Australia Enable AI
sourceDocumentLink: https://www.servicenow.com/docs/r/australia/intelligent-experiences

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia Enable AI

ft:clusterId :

    - platai

bundleId :

    - platai

workflow :

    - Platform


---

# Using regular expressions in entities

# Using regular expressions in entities {#ariaid-title1}

Release version: Australia  
Updated March 12, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read  
Learn how to use regular expressions in your NLU entities to establish patterns that help the system locate, match, and manage text.

Pattern entities use regular expressions (regex) to match any pattern of text, such as the
format of an email address, a phone number, or an incident or case ID.  
Note:  
ServiceNow uses and supports Java regex exclusively and not other vendor options, such as Perl regex.

## Regex examples {#using-regular-expressions-nlu__section_bfz_fbx_nhb}

For a full example of regex code used in a pattern entity, see [Create a pattern entity](https://www.servicenow.com/docs/KiiztyFnENsKU7pKAk_Igw "Create a pattern entity from a word or phrase with repeatable patterns, such as email addresses and phone numbers. These patterns help the system to recognize similar utterances based on the patterns.").

The following four examples provide the format and regex code for different pattern
entities.  

Knowledge base article
:   ServiceNow Knowledge Base (KB) articles use the format KB1234567. The
    regex code is KB\\d{7}, where KB = knowledge base record and
    d{7} = 7 digits.

Case number
:   Case tasks use the format CS1234567. The regex code is
    CS\\d{7} where CS = case record and d{7} = 7
    digits.

Email address
:   Email addresses use the format name@servicenow.com. The regex code is
    \\b\[a-zA-Z0-9\&\*/_.+-\]+@\[a-zA-Z0-9-\]+\\.\[a-zA-Z0-9-.\]+\\b, which
    supports these formats: name@servicenow.com and
    name@servicenow.co.in.

Phone number
:   United States phone numbers use the format 555-123-4567. The regex code
    is \\d{10}\|(?:\\d{3}-){2}\\d{4}\|\\(\\d{3}\\)\\d{3}-?\\d{4}, which supports these
    formats: 5108882062,510-888-2062, and
    (510)888-2062.

## Regex resources {#using-regular-expressions-nlu__section_rbt_dtd_b3b}

For further information on regular expressions, see the following external links.

* [Java Regular Expressions](https://www.tutorialspoint.com/java/java_regular_expressions.htm)
* [Java Regular Expression Tester](https://www.freeformatter.com/java-regex-tester.html#documentation)
* [Pattern (Java Platform SE7)](https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html)
* [Java regex match abbreviations](https://blog.softhints.com/java-regex-extract-abbriviations/)
{#using-regular-expressions-nlu__ul_tkw_5vr_b3b}

