User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

profimail:regex [2013/03/05 14:13] (current)
Line 1: Line 1:
 +===== Regular expressions =====
 +What are regular expressions? In short, this is syntax for flexible matching of text (searching elements inside of text) by writing a formula with wild-cards and patterns.
 +Learn more here: [[wp>Regex]]
 +What are Regular expressions good for in ProfiMail? They may be used in [[.:rules|Rules]] for writing Rule condition to match text (for example in message subject or header).
 +Here is good online regex tester for playing with: [[|]]
 +==== Quick reference to regex syntax ====
 +|.|Any character ((except newline))|
 +|\.|period ((\ escapes also other characters such as: \* \( \\\\ ))|
 +|%%^%%|start of string|
 +|$|end of string|
 +|\d, \w, \s|digit, word character [A-Za-z0-9_], or whitespace|
 +|\D, \W, \S|anything except digit, word character, or whitespace|
 +|[abc]|character a, b, or c ((matches any character that is included in brackets))|
 +|[a-z]|a through z ((matches any character that is in given range of characters))|
 +|[%%^%%abc]|any character except a, b, or c|
 +|aa%%|%%bb|either aa or bb|
 +|?|zero or one of preceding element|
 +|*|zero or more of preceding element|
 +|+|one or more of preceding element|
 +|{n}|exactly n times of preceding element|
 +|{n,}|n or more times of preceding element|
 +|{m,n}|between m and n times of preceding element|
 +|??, *?, +?, {n}?|same as above, but as few as possible|
 +|(expr)|capture expr for use with \1, etc|
 +|(?:expr)|non-capturing group|
 +|(?=expr)|followed by expr|
 +|(?!expr)|not followed by expr|
 +==== Simple example ====
 +For example, you may want to create a Rule to find messages sent from // or from // You could write separate Rule condition with all possible email addresses to search for, or you can use regular expression:
 +   (josh|mary)
 +Which means to search for text that begins with //josh// OR //mary// followed by //
 +To extend the example, here is formula to match any email address from // domain:
 +   \
 +That means any word character occurring one or more time before text //
 +For the rest, you can make your own tests in this [[|online tester]], or try this in [[.:activity:rules_editor|Rules]].
profimail/regex.txt · Last modified: 2013/03/05 14:13 (external edit)