Navigation: X4D Data Import > XDI Administration > Regular Expressions >

Cheat Sheet Common Pattern and  expressions

 

 

 

 

1. Basics

Expression

Description

.

Any character except a newline

^

Start of a string

$

End of a string

\

Escape special characters (e.g., \. matches a literal dot)

 

2. Character Classes

Expression

Description

[abc]

Matches a, b, or c

[^abc]

Negation: Matches anything except a, b, or c

[a-z]

Matches any lowercase letter (a to z)

[A-Z]

Matches any uppercase letter (A to Z)

[0-9]

Matches any digit (0 to 9)

[a-zA-Z0-9_]

Matches any alphanumeric character


3. Quantifiers

Expression

Description

*

0 or more times (greedy)

+

1 or more times (greedy)

?

0 or 1 time (optional)

{n}

Exactly n times

{n,}

At least n times

{n,m}

Between n and m times


4. Grouping & Alternation

Expression

Description

(abc)

Grouping: Matches abc and captures it

(?:abc)

Non-capturing group

`a

b`


5. Assertions (Lookaheads & Lookbehinds)

Expression

Description

(?=abc)

Positive lookahead: Ensures abc follows but doesn’t consume it

(?!abc)

Negative lookahead: Ensures abc does NOT follow

(?<=abc)

Positive lookbehind: Ensures abc precedes

(?<!abc)

Negative lookbehind: Ensures abc does NOT precede


6. Anchors & Word Boundaries

Expression

Description

\b

Word boundary

\B

Not a word boundary


7. Common Escapes

Expression

Description

\d

Any digit [0-9]

\D

Any non-digit [^0-9]

\w

Any word character [a-zA-Z0-9_]

\W

Any non-word character [^a-zA-Z0-9_]

\s

Any whitespace (spaces, tabs, newlines)

\S

Any non-whitespace


8. Common Examples

Pattern

Matches

^\d{3}-\d{2}-\d{4}$

Matches SSN format (e.g., 123-45-6789)

`\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Z

a-z]{2,7}\b`

https?://\S+

Matches a URL

\b\d{3}-\d{3}-\d{4}\b

Matches phone number (123-456-7890)

 

 

 

Copyright © 2025 CAD Global Inc.