The following examples illustrate the use and construction of simple regular expressions. Each example includes the type of text to be matched, one or more regular expressions to match that text, and notes explaining the use of special characters and formatting.
- Exact phrase match only
- Combine words or phrases in a list
- Combine words with different spellings or special characters
- Match any email address from a specific domain
- Matches any IP address in a range
- Match an alphanumeric format
For additional instructions and guidelines, see alsoGuidelines for using regular expressionsyRE2 Syntax. See tooConfigure rules for content compliance.
Important:we supportRE2 Syntaxonly, it differs slightly from PCRE. Regular expressions are case sensitive by default.
Use:The examples below can be useful as starting points for more complex regular expressions. However, to match a single word, we suggest you use thecontent complianceoobjectionable contentDefinitions.
Exact phrase match only | |
---|---|
Example of use | Combine a frasestock tips. |
Examples of regular expressions | Example 1:(\W|^)estoque\stips(\W|$) Example 2:(\W|^)stock tips{0,3}(\W|$) Example 3:(\W|^)stock\s{0,3}consejo(s){0,1}(\W|$) |
grades |
|
Combine words or phrases in a list | |
---|---|
Example of use | Combine any word or phrase from the following list:
|
Regular Expression Example | (?i)(\W|^)(nonsense|damn|merda|fooey|OMG\damn|heck)(\W|$) |
grades |
|
Combine words with different spellings or special characters | |
---|---|
Example of use | Combine the word viagra with some of the obfuscations spammers use, such as:
|
Regular Expression Example | v[i!1][a@]gr[a@] |
grades |
|
Match any email address from a specific domain | |
---|---|
Example of use | Match any domains email addressyahoo.com,hotmail.com, yougmail.com. |
Regular Expression Example | (\W|^)[\w.\-]{0,25}@(yahoo|hotmail|gmail)\.com(\W|$) |
grades |
|
Matches any IP address in a range | |
---|---|
Example of use | Matches any IP address within range192.168.1.0an192.168.1.255. |
Examples of regular expressions | Example 1:192\.168\.1\. Example 2:192\.168\.1\.\d{1,3} |
grades |
|
Match an alphanumeric format | |
---|---|
Example of use | Combine your company's purchase order numbers. This number has several possible formats, such as:
|
Regular Expression Example | (\W|^)po[#\-]{0,1}\s{0,1}\d{2}[\s-]{0,1}\d{4}(\W|$) |
grades |
|
Was it helpful?
How can we improve?
Need more help?
Sign up for additional support options to quickly resolve your issue
Check-in
Start your 14-day free trial today
Professional email, online storage, shared calendars, video conferencing and more.Start your free Google Workspace trial today.