Regular Expressions
With Regular Expressions, you can define complex search and filter expressions. All Regular Expressions are case insensitive by default.
Regex functions
Regular Expressions must be placed in one of the following functions:
- regex( ... )
Filters the specified Regular Expression.
For example: regex(\d+ downloads) - FirstRegex( ... )
Filters only the first occurrence of the specified Regular Expression.
For example: FirstRegex(\d+ downloads) - StartToRegex( ... )
Filters everything from the beginning of the page up to the first occurrence of the specified Regular Expression.
For example: StartToRegex(\d+ visitors) - RegexToRegex( ... , ... )
Filters everything between two Regular Expressions.
For example: RegexToRegex(Downloads\: \d+,License\:) - RegexToEnd( ... )
Filters everything from the last occurrence of the specified Regular Expression to the end of the page.
For example: RegexToEnd(\d+ users online) - RegexCmp( ... )
Finds a specified Regular Expression, extracts all digits from the result, and compares them with a predefined number. This can be used, for example, to extract and compare prices. A match can be accepted only if the extracted value is greater than 1000.
For example: RegexCmp(\d+(\[,\.]\d+)* Euro; , ; > 1000)
The RegexCmp function can be used in the Keywords functionality, Ignore filters, and Watch filters. A detailed description is provided below.
Tokens of Regular Expressions
Below is a list of commonly used Regular Expression tokens.
|
\ |
The backslash escapes any character and can therefore be used to force characters to be matched as literals instead of being treated as characters with special meaning. For example, '\[' matches '[' and '\\' matches '\'. |
|
. |
A dot matches any character. For example, 'go.d' matches 'gold' and 'good'. |
|
{ } |
{n} ... Match exactly n times {n,} ... Match at least n times {n,m} ... Match at least n but not more than m times |
|
[ ] |
A string enclosed in square brackets matches any character in that string, but no others. For example, '[xyz]' matches only 'x', 'y', or 'z', a range of characters may be specified by two characters separated by '-'. Note that '[a-z]' matches alphabetic characters, while '[z-a]' never matches. |
|
[-] |
A hyphen within the brackets signifies a range of characters. For example, [b-o] matches any character from b through o. |
|
| |
A vertical bar matches either expression on either side of the vertical bar. For example, bar|car will match either bar or car. |
|
* |
An asterisk after a string matches any number of occurrences of that string, including zero characters. For example, bo* matches: bo, boo and booo but not b. |
|
+ |
A plus sign after a string matches any number of occurrences of that string, except zero characters. For example, bo+ matches: boo, and booo, but not bo or be. |
|
\d+ |
Matches all numbers with one or more digits. |
|
\d* |
Matches all numbers with zero or more digits. |
|
\w+ |
Matches all words with one or more characters containing a-z, A-Z and 0-9. \w+ will find title, border, width etc. Please note that \w matches only numbers and characters (a-z, A-Z, 0-9) lower than ordinal value 128. |
|
\s |
Matches whitespace, such as space, tab, or line break. |
|
.*? |
Matches as few characters as possible. a.*?b means: "find "a", followed by as few characters as possible, followed by "b |
|
[a-zA-Z\xA1-\xFF]+ |
Matches all words with one or more characters containing a-z, A-Z and characters larger than ordinal value 161 (eg. ä or Ü). If you want to find words with numbers, then add 0-9 to the expression: [0-9a-zA-Z\xA1-\xFF]+ |
RegexCmp(...)
The RegexCmp function finds a specified Regular Expression, extracts all digits from the result, and compares them with a predefined number. If the comparison returns true, the match is accepted.
This function requires three parameters separated by the ';' character. The exact syntax is:
regexcmp(regular expression; decimal point character; operator number)
Parameters:
- regular expression
This Regular Expression extracts specific numbers from a page. The result can contain text and numbers, for example a match such as "Price: 49,00 Euro". The RegexCmp function extracts all digits from the result and compares the extracted number. - decimal point character
Defines whether a dot or a comma is used as the decimal point character in the page. Valid values are "." and "," without quotes. - operator number
Valid operators:
= ... equal
< ... less than
<= ... less or equal than
> ... greater than
>= ... greater or equal than
<> ... not equal
The number defines the comparison value and can optionally contain a decimal point character, for example 49,95 or 49.95. Thousands separators are not allowed.
Example:
regexcmp(\d+([,\.]\d+)* Euro;,; > 49.95)
- The first parameter searches for the Regular Expression "\d+(\[,\.]\d+)* Euro" and extracts all digits from the result, including the decimal point character, for example 1449,95.
- The second parameter defines the decimal point character, in this example ",".
- The third parameter checks whether the extracted price is greater than 49.95.
- If the extracted price is less than or equal to 49.95, the match is ignored. If it is greater than 49.95, the match is accepted.
Typical examples
- regex(bo*)
Finds "b", "bo", "boo", "booooo" - regex(bx+)
Finds "bxxxxxxxx", "bxx", "bx" but not "b" - regex(\d+)
Finds all numbers. - regex(\d+ visitors)
Finds "3 visitors" or "243234 visitors" or "2763816 visitors" - regex(\d+ of \d+ messages)
Finds "2 of 1200 messages" or "1 of 10 messages" - RegexToEnd(\d+ of \d+ messages)
Filters everything from the last occurrence of "2 of 1200 messages" or "1 of 10 messages" to the end of the page. - regex(MyText.{0,20})
Finds "MyText" and the next 20 characters after "MyText". - regex(\d\d.\d\d.\d\d\d\d)
Finds date strings with the format 99.99.9999 or 99-99-9999 (because the dot matches any character) - regex(\d\d\.\d\d\.\d\d\d\d)
Finds date strings with the format 99.99.9999 - regex(([_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+))
Finds email addresses. - regexcmp(\d+([,\.]\d+)* Euro;,; > 49.95)
Finds prices in the format "9.999,99 Euro" and accepts only results where the price is higher than 49,95 Euro.