Easy GREP RegEx can be written in the syntax of Javascript and VBscript which covers most of the usually used.
Key | Description | Example | Explanation |
---|---|---|---|
^ | start of line | ^On | Key word "On" must be the first word of a line |
$ | end of line | ||
. | Anything except line feed | One character, similar as ? in Windows wildcard | |
X* | Preceding expression exists any times or not | (.|\n)* | Matches nothing or anything(even paragraphs) of any length |
X+ | Preceding expression exists once or more | (.|\n)+ | Anything(except nothing) of any length(>=1) |
? | Exists once or not | ( | Such as a,b,c or A,B,C |
(XX) | Make a group of characters, so that we can add other metacharacter behind or reference it in result | (ab) | Letter "a" and letter "b" share the same group |
[XX] | Make a class of characters, can match any characters inside. | [ab] | Letter "a" or letter "b" |
(A|B) | Similar as [AB], but A and B can be any length of characters, like word | (a|abc) | Letter "a" or word "abc" |
| | Either of two sides can match. | ||
[^X] | A class of all characters except the characters inside | [^a] | Anything except letter "a" |
{a} | Preceding expression should be repeated a times. | {3} | Exists three times |
{a,b} | Preceding expression should be repeated from a times to b times. | {1,3} | Exists one to three times |
()? | Preceding expression exists once or not. | (a)? | Letter "a "exists or not |
? | Match only to the nearest expression followed | \.+?> | Till the first ">" |
Key | Abbr. of | Description | Example | Explanation |
---|---|---|---|---|
\d | Digit | means a number | Such as 1,2,3 | |
\b | Boundary | means a word boundary. (Some other types of RegEx use \< and \> do the same thing.) | \bsome\b | Only word "some" matches, "something" or "handsome" doesn't match |
\r | Return | means carriage return | For Mac system | |
\n | Newline | means newline | For Windows system | |
\r\n | whole line break | Mostly for Windows system, also used in most files for cross-platform | ||
\w | Word | Match any alphabetic character number and underscore. Match a whole word should be \b\w+\b | Such as a,b,c or A,B,C | generally equals to [a-zA-Z0-9_] |
\s | Space | means white space, match space, tab and linebreak. | Such as space or tab | generally equals to [ \t\r\n] |
\t | Tab | Tab character | ||
\W ... | An upper case means the negative class of the lowercase one means, reversed range.Such as \W match anything \w not match |