...
Simple Examples
Table plus |
---|
|
| |
| ABC | ABC.* | |
|
| ABCD | ABC.* | | |
| ABC | [ABCD] | | [ ] indicates a class of characters | ABC | [ABZ] | | |
| image.jpg | .*png|.*jpg | |
| |
| 112233 | \d+ | | \d for digits | A B | A\s*B | | \s for whitespace | ABC | \S* | | \S for non whitespace | |
| \S+ | | Value must have at least 1 non whitespace character | A | \S+ | |
|
| XYZ,ABC,UVW | .*\bABC\b.* | | Word boundaries. Finding words in a comma or blank separated list using word boundaries | XYZ,ABCD,UVW | .*\bABC\b.* | |
|
| ABC | (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$) | | Looking for text matches in a comma separated list by covering all cases: only, start, middle, and end. This uses the multi-line flag: (?m). | XYZ,ABC,UVW | (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$) | | |
| XYZ,ABC DEF,UVW | (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$) | |
|
Advanced Examples
| | | Find | Demonstrates |
---|
example.txt | ^((?!\.png).)*$
| | |
Match Find string not containing a word. In this example, files that do not have a .png extension |
example.png | ^((?!\.png).)*$
| |
Match | Find string not containing a word. In this example, files that do not have a .png extension |
example.jpeg | (?=^((?!\.png).)*$)(?=^((?!\.jpeg).)*$) | | | Find string not containing a word. In this example, files that do not have a .png or .jpeg extension |
collateral wholesale retail | .*(?=.*\bretail\b.*)(?=.*\bcollateral\b.*).* | |
| Match exact words anywhere in string. In this case a blank separated list of labels and we require both collateral and retail to be included before we want the match to be successful |
wholesale retail | .*(?=.*\bretail\b.*)(?=.*\bcollateral\b.*).* | |
| Both are required for a match |
merger acquisition | .*\b(?:merger|acquisition)\b.* | |
| Match string containing either word |
Filter by label (Content by label) |
---|
showLabels | false |
---|
excerpt | true |
---|
title | Content with regex label |
---|
excerptType | simple |
---|
cql | label = "regex" |
---|
labels | regex |
---|
|
...
- RegexOne - interactive tutorials to learn how to construct regular expressions
- Regexlib.com - searchable collection of user-contributed regular expressions
- RegexPlanet test site - test your expressions quickly
- Regex101 test site - understand a regex expression and test it
- Wikipedia regular expressions
- Regular expression reference
- Quick reference - best once you have the concepts
- Using word boundaries
- Regular expression to match string not containing a word?
...