Match
Last updated
Was this helpful?
Last updated
Was this helpful?
Match allows you to test whether or not a string is the same as a text value you provide. This can be a specific value, or a a more complex match using Regular Expressions (regex) - a powerful and commonly used form of syntax for searching for patterns of characters e.g. in search engines.
With most tools, match returns a True|False, but in Excel match returns the index within a range of cells of a cell that meets your criteria. This can be combined with an INDEX
function to reference values in multiple tables, see .
=~MATCH!~(‹target_string›, ‹within_array›«, match_type»)
Match Type Options:
"0": MATCH
finds the first value that is exactly equal to ‹target_string› and returns its index. The values in the ‹within_array› argument can be in any order.
"1" or omitted: MATCH
finds the largest value that is less than or equal to ‹target_string› and returns its index. The values in the ‹within_array› argument must be placed in ascending order, for example: -1, 0, 1, 2, 3, A-Z, FALSE, TRUE
"-1": MATCH
finds the smallest value that is greater than or equal to ‹target_string› and returns its index. The values in the ‹within_array› argument must be placed in descending order, for example: TRUE, FALSE, Z-A, 3, 2, 1, 0, -1
Tableau has no Match function so use an IF()
to test for exact matches.
~REGEX_MATCH!~(‹within_string›, "‹target_string›") where the result is only true when the ‹target_string› exactly matches the ‹within_string›.
In OrgVue, match()
can be used to find specified strings and also in conjunction with Regular Expressions.
Example 1 - String matching:
Example 2 - Sophisticated matching of characters:
Example 3 - Pattern matching:
Example 1 - String matching: ‹within_field› ~LIKE!~ "‹target_string›"
Example 2: Instead of matching a specified strings, you can also use pattern matching, similar to Regular Expressions - a powerful and commonly used form of syntax for searching for patterns of characters e.g. in search engines. tSGL supports the following 'wildcard characters' in a pattern:
%
- match any string of 0+ characters
_
- match any single character
[]
- match any single character within the range specified in brackets
[^]
match any single character not within the range specified in brackets
In Python, matching can be done on specified strings and also in conjunction with Regular Expressions. Example 1 - String matching: ‹target_string› ~in!~ ‹within_string›
Example 2 - Sophisticated matching of characters: ~re.search!~(‹pattern›, ‹field›)
NB.:
This requires the Regular Expressions library to be imported (import re
).
NB. The ‹target_string› can also be defined using Regular Expressions, or using the RegEx tool (in the Parse palette): or the Fuzzy Match tool (in the Join palette):
which allows you to test for approximate matches based on user-defined or standard-algorithm parameters.
NB. For more information about the match()
syntax, see the summary of Regular Expressions (Regex) or test them out yourself at .
For more examples, go to: .
The above examples assume variables have been declared for jobTitle
and niNumber
. For more information, go to .