Regular expressions and patterns in field normalization rules

  • Release version: Australia
  • Updated March 12, 2026
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Regular expressions and patterns in field normalization rules

    This content explains how ServiceNow supports the use of regular expressions (regex) and pattern matching within field normalization rules to transform field values. These capabilities enable precise identification and modification of specific characters or substrings in field data during transformation processes.

    Show full answer Show less

    Key Features

    • Regular Expressions in Transformations: Regex can be used in transform parameters and condition statements to locate characters or substrings within field values for transformation.
    • Regex Syntax Requirement: Regex parameters must begin with /regex/ followed by the pattern to define the character position or substring location.
    • Transformation Actions: After identifying target characters via regex, the transformation can replace, delete, or insert characters at those positions.

    Practical Example

    A network administrator wants to normalize computer names in the cmdbcicomputer table by removing the domain prefix and backslash from names like development\devlab01. Since domain names vary but all names contain a backslash, the admin uses a regex transform:

    • Find: /regex/.\\(.) — matches the entire string, capturing only the machine name after the backslash.
    • Replace with: $1 — replaces the full string with the captured machine name portion.

    The backslash is escaped as \\ in the regex to match the literal character. Testing this transform converts development\devlab01 to devlab01. Once confirmed, the transformation is activated and applied to existing records via the Transformation application data job.

    Benefits for ServiceNow Customers

    • Enables precise and flexible normalization of field data across various tables and fields using regex patterns.
    • Reduces manual data cleanup by automating transformations based on pattern matching.
    • Supports complex scenarios where only parts of a field value need alteration, improving data consistency.
    • Provides a test mechanism within transformation records to validate regex transforms before activation.

    Field Transformation definitions support the use of regular expressions (referred to in the platform as regex) and pattern matching for determining the position of characters in a string.

    After identifying the target characters, field transformation can replace or delete the identified characters or insert other characters at that position.

    Regex

    Regular expressions can be used in transform parameters and in condition statements to determine which characters in a field value are transformed.

    Regular expressions used as parameters to locate characters in transformed field values must begin with /regex/. Everything after that is a regular expression that is used to calculate character position.

    Example

    The computer names in an organization's Windows network are expressed as domain\machine name, such as development\devlab01. The network administrator wants to simplify these names by removing the domain name and backslash. He creates a transformation record for the Computer [cmdb_ci_computer] table and selects the Name field to transform.

    The network contains several domains, and each domain contains numerous computers. The only character common to each name is the backslash. To delete the domain name, the administrator decides to use a regular expression to replace the entire raw value in the field with the characters that appear after the backslash (the actual machine name). He creates a new Transform using Replace as the Transform Type and enters the following values:
    • Find:/regex/.*\\(.*)
    • Replace with:$1

    The regular expression .*\\(.*) represents the entire raw value in the Name field - in this example development\devlab01. The first part of the expression, .*, represents everything before the backslash (the development domain name). The backslash by itself is the escape character in regular expressions and requires special syntax to retain its function in the computer name. The administrator must escape it by using another backslash (\\ means \). The part of the expression after the backslash, (.*), represents the computer name (devlab01) and is grouped within parentheses for reference. The value in the Replace with field, $1, references this group and replaces the entire raw value of the field with the contents of the group, devlab01.

    The administrator clicks Test transforms in the transformation record and enters development\devlab01 in the Raw data field. He then clicks OK to apply the transform to the test value. The transform replaces development\devlab01 with devlab01.

    When the transforms for this field are tested successfully, the administrator changes the Mode in the transformation record to Active and runs the Transformation application data job to apply this transformation to existing records in the database.