Search text for the first match of a pattern.
Input Fields
- look in is the text you want to search inside.
- look for is the text you want to search for and/or pattern to match. Patterns must follow a standard pattern format called a regular expression (see details below).
Output Fields
- position is the position where the first match begins, where 0 denotes the very beginning. Returns -1 if there is no match.
Pattern Options
Unlike the Find function, Find Pattern also supports regular expressions. Examples of regular expressions include:
\w
- finds any alphanumeric character (e.g. a letter or number)\s
- finds any whitespace character (e.g. a blank or tab)\d
- finds any digit[1-5]
- finds a number between 1 and 5[aeiou]
- finds a, e, i, o, or uhello|test
- finds “hello” or “test”colou?r
- finds “color” or “colour” (the?
signifies that there can be zero or one of the preceding element)\d{5}
- finds five consecutive digits (the{number}
signifies a number of consecutive instances of the preceding element)[^\w]
- finds any character that is not an alphanumeric character. You can add the not operator^
before any other pattern, e.g.[^a]
to find anything other thana
or[^\d{3}]
to find anything that is not 3 digits in a row
Many characters have special meaning in regular expressions, such as .
, +
, *
, \
and more. To search for any of those characters you need to place a \
before the character. For instance:
* \.
- finds a period
You can combine any of the above patterns and fixed text. For instance:
* test\.\d{3}
- finds the word “test” followed by a period followed by 3 consecutive digits
Examples:
For simple searches, Find Pattern works the same as Find.
If look in testing_123
:
- look for
test
-> position0
(found at very beginning) - look for
ing
-> position4
(4 means it comes after the 4th, starts in the 5th position) - look for
hello
-> position-1
(no match found) - look for
\d
-> position8
(first digit) - look for
\w_\d
-> position6
(any character then underline then any digit) - look for
esting_\d{3}
-> position1
(“esting_” followed by any 3 digits)
Find Pattern is often used in combination with Text Segment to get the text that matched the pattern.