Pattern Matching
What's Pattern Matching ?
With Pattern Matching, you specify a pattern which tells Tasker what text you wish
to match. For instance, if you want to match any telephone number starting with 0135, you
can specify the match 0135*. * is a special character which matches
any number of any character.
Where's It Used ?
Matching is used in the following places:
- in the If condition of an action, when the ~ (match) or !~ (not match) operators
are specified.
- in text paremeters of State and Event contexts
- some other places :-)
Matching Rules
- if a pattern is left blank, it will match against anything
- if it is not blank it must match the whole target text
- / means 'or', it divides up multiple possible matches
- a * will match any number of any character. It's not possible to specifically
match a * character.
- a + will match one or more of any character. It's not possible to specifically
match a + character.
- matching is case-insensitive (magic will match with MagiC)
unless the pattern contains an upper-case letter e.g. Magic* will
not match against magically, but it will match against Magic Roundabout
- a ! at the very start of a match means not e.g. !*Magic*/*Yellow* matches anything not
containing the words Magic or Yellow
- it is not possible to specifically match a ! character at the start of a target (but you could
use *!
Examples
- help matches help but not helper.
- help* matches helper
- *the* matches the (anywhere)
- 123+ matches 123 and minimally one more character
- + matches anything with at least one character (non-empty)
- the*way matches the other way and the first way, amongst others
- Help/*shell matchs Help or anything ending with shell, case-sensitively
Caller Matching
Caller matching (some events and states e.g. Incoming Call) is handled slightly differently.
- C:ANY matches the telephone number of any contact
- C:FAV matches the telephone number of any favourite (starred) contact
- Otherwise: otherwise a match is attempted using the general matching rules
against both the caller phone number and the associated contact's name (if there
is one).
Examples:
- !C:ANY matches a number not belonging to a contact
- 077*/Geoff* matches a number starting with 077 or belonging to a contact
whose names starts with Geoff
- C:FAV/0123456789
matches any favourite contact or the telephone number 0123456789