Updated on 2026-09-24 GMT+08:00

Regular Expression Syntax

When configuring custom sensitive data rules, the system supports creating custom sensitive data discovery rules using regular expressions.

Regular expressions are a set of rules used to describe text matching patterns. When defining sensitive data discovery rules, you can use regular expressions to define the characteristics of sensitive data; the system will then automatically scan and match any data that meets these characteristics.

Table 1 Common grammar notes

Grammar

Meaning

Matching Example

.

Matches any single character (except the line feed character)

A.C can be matched with ABC, A1C, or A-C.

\d

Matches any single digit (equivalent to [0-9])

\d{6} matches 123456

\D

Matches any non-numeric value

\D+ can match abc or a name

\w

Match a single letter, digit, or underscore.

\w+ can match abc123_

\s

Matches a whitespace character (space, newline, tab, etc.)

a\sb matches a b

[abc]

Matches any character within the square brackets.

[abc] matches a, b, or c

[0-9]

Matches any character within the specified range.

[0-9] matches any digit; equivalent to \d

[a-zA-Z]

Matches any English letter

[a-zA-Z]{3} can match ABC, xyz

[\u4e00-\u9fa5]

Matches any Chinese character

[\u4e00-\u9fa5]{2,4} can match Zhang San or Ouyang Xue

[^abc]

Matches any character except those within the square brackets.

[^0-9] Matches non-digit characters

^

Match the beginning of a string

^[0-9] matches a string that starts with a digit

$

Match the end of a string

[0-9]$ matches strings that end with a digit

?

The preceding character appears 0 or 1 time.

a? Matches "" or a

{n}

The preceding character appears exactly n times.

\d{11} matches 11-digit numbers

{n,m}

The preceding character appears n to m times.

\d{6,10} matches 6 to 10 digits.

|

Or logic – matches either the left or the right side.

Male | Female – Can match with either male or female

()

Grouping: treats multiple characters as a single unit.

(ab) + matches ab and abab

\

Escaping: matches the special character itself.

\. Matches a dot; \* Matches a asterisk

(?i)

Case-insensitive

(?)abc can match both abc and ABC.

Table 2 Common regular expression examples for sensitive data detection

Data Type

Regular Expression

Description

ID number

\d{15}|\d{17}[\dXx]

Both 15-bit and 18-bit formats are supported.

Chinese name

[\u4e00-\u9fa5]{2,4}

2–4 Chinese characters

cell-phone number

1[3-9]\d{9}

Starts with 1, the second digit ranges from 3 to 9, followed by a 9-digit number.

landline telephone

0\d{2,3}-\d{7,8}

e.g.: 010-12345678

e-mail address

\w+@\w+\.\w+

Simple email format

Bank card number

\d{16,19}

16–19-digit pure number

Organizational Code

[0-9A-Z]{8}[-]?[0-9X]

e.g.: 12345678-9

Business License Number (18 digits)

[0-9A-Z]{18}

18-digit or 18-character string

zip code

\d{6}

6-digit pure number

Amount (two decimal places)

\d+(\.\d{1,2})?

e.g.: 123,123.45

IPv4 address

((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)

Standard IP Format

Table 3 Configuration notes

Matters Needing Attention

Description

Escape special characters

For special characters such as, *, +,?, \, (,) or other reserved characters, you must escape them by prefixing them with a \; for example, \. The matching dot character is used for matching a single character.

Chinese Matching

Use [\u4e00-\u9fa5] to represent a single Chinese character.

Case-insensitive

Adding (?i) before an expression (e.g., (?i)abc) allows it to match abc, ABC, and Abc.

Matching Method

The system defaults to exact match; there is no need to manually add ^ or $ symbols. If you want to match a partial segment of a field, use the start-or end-wildcard characters, e.g., ".ID Card.*".