IsMatch, Match and MatchAll functions without Power Apps - Power Platform (2023)

  • Article
  • 12 minutes to read

Try a match or extract parts of a text string based on a pattern.

Description

DieEsMatchThe function checks if a text string matches a pattern, which can be regular characters, predefined patterns, or a pattern.regular phrase. DieRollomimatch allThe functions return what was matched, including any submatches.

UseEsMatchto validate what a user has enteredtext inputto control. For example, you can confirm that the user has entered a valid email address before saving the result to your data source. If the input doesn't match your criteria, add other controls that prompt the user to correct the input.

UseRolloto extract the first text string matching a pattern andmatch allto extract all matching strings. You can also extract submatches to analyze complex strings.

Rolloreturns a record of information for the first match found, andmatch allreturns a table of records for each match found. The record or records contain:

ShareuntilDescription
named submatch or submatchesTextEach named partial match has its own column. Create a named partial match using(?<Name>...)in the regular expression. If a named submatch has the same name as one of the predefined columns (below), the submatch takes precedence and a warning is generated. To avoid this warning, rename the submatch.
whole gameTextThe entire matching text string.
start gamenumberThe starting position of the match in the input text string. The first character of the string returns 1.
partial matchesSingle column text table (columnWert)The table of named and unnamed submatches in the order they appear in the regular expression. In general, working with named submatches is easier and recommended. Use theFor allfunction oTo last(first(...) ) works to work with a single submatch. If no submatches are defined in the regular expression, this table exists but is empty.

supports these functionsMatch Options. Default:

  • These functions perform a case-sensitive comparison. Useignore casePerforms case-insensitive matches.
  • EsMatchmatches the entire text string (CompletelyMatchOption), whileRollomimatch allSearch for a match anywhere in the text string (containsmatch option). UseCompletely,contains,Starts with, oends withaccording to your scenario.

EsMatchReturnsThis rightif the text string matches the pattern orINCORRECTunless.RolloReturnsArchiveif no match is found, you can try withIt is emptyOccupation.match allreturns an empty table if no matches are found to try withIt is emptyOccupation.

and usematch allTo split a string of text, consider usingdivisionsEasier to use and faster function.

Get together

The key to using these functions is to describe the pattern to be compared. The pattern is described in a text string as a combination of:

  • common characters like"A B C"o"123".
  • Preset patterns likepresentation,multiple digits, oThe email. (DieRolloenum defines these default values).
  • Regular expression codes like"\d+\s+\d+"o"[a-z]+".

Combine these elements using the. For example,"abc" & Ziffer & "\s+"is a valid pattern that matches the characters "a", "b", and "c" followed by a digit from 0 to 9, followed by at least one space.

common characters

The simplest pattern is a sequence of common characters that must match exactly.

For example, when used with theEsMatchfunction, the string "Hello" matches the pattern"Hola"exactly. No more no less. The string "Hello!" does not match the pattern due to the exclamation mark at the end and the incorrect case of the letter "h". (To seeMatch Optionsfor ways to change this behavior).

In the standard language, certain characters are reserved for special purposes. To use these characters, precede the character with\(backslash) to indicate that the character is to be understood literally, or use one of the predefined patterns described later in this topic. This table lists the special characters:

special characterDescription
.point or point
?Interrogation point
*asterisk
+More
( )brackets
[]brackets
{}Chaves
^Caution
psDollar sign
|rod or standpipe
\Backslash

For example, you can say "Hello?" using the pattern"Hola\?"with a backslash before the question mark.

predefined patterns

Predefined patterns provide an easy way to match a set of characters or a sequence of multiple characters. Use theto combine your own text strings with members of theRolloTell:

corresponding numberDescriptionregular phrase
NeitherMatches any character..
ForIt coincides with a coma.,
digitIt coincides with a single digit ("0" to "9").\d
The emailMatches an email address that contains an "at" symbol ("@") and a domain name that contains a period (".")..+\@.+\\.[^\\.]{2,}
screenplayMatches a hyphen.\-
by LeftPaMatches a left parenthesis "(".\(
presentationMatches a letter.\p{L}
multiple digitsMatches one or more digits.\d+
various lettersMatches one or more letters.\p{L}+
multiple non-spacesMatches one or more non-space characters (no spaces, tabs, or newlines).\S+
multiple spacesMatches one or more characters that add spaces (space, tab, or newline).\s+
non-spatialMatches a single character that does not add spaces.\S
optional digitsMatch zero, one or more digits.\d*
optional lettersMatches zero, one, or more letters.\p{L}*
OptionalNoSpacesMatches zero, one, or more non-space characters.\S*
optional spaceMatches zero, one, or more characters by adding spaces.\s*
PeriodCoincide con un punto o punto (".").\.
Right ParameterMatches a right parenthesis ")".\)
plazaMatches a character by adding spaces.\s
abaMatches a tab character.\t

For example, the default"A" and multiple digitsmatches the letter "A" followed by one or more digits.

regular expressions

The pattern that these functions use is aregular phrase. The common characters and predefined patterns described earlier in this topic help you build regular expressions.

Regular expressions are very powerful, available in many programming languages, and used for many purposes. They can also look like a random string of punctuation marks. This article doesn't cover every aspect of regular expressions, but there is a wealth of information, tutorials, and tools available on the web.

Regular expressions come in different dialects, and Power Apps uses a dialect variant of JavaScript. To seeregular expression syntaxfor an introduction to the syntax. Named submatches (sometimes called named pickup groups) are supported:

  • Named Submatches:(?<Name> ...)
  • Named Backlinks:\k<Name>

I'mRolloEnum table earlier in this topic, each enum appears on the same line as its corresponding regular expression.

game options

You can change the behavior of these functions by specifying one or more options, which can be combined using the string concatenation operator (&).

MatchOptions enumerationDescriptionEffect on a regular expression
Starts withThe pattern must match from the beginning of the text.inserts^at the beginning of the regular expression.
Completelystandard forEsMatch. The pattern must match the entire text string from start to finish.inserts^to start and onepsat the end of the regular expression.
containsstandard forRollomimatch all. The pattern must occur somewhere in the text, but it doesn't have to start or end.It does not change the regular expression.
ends withThe pattern must match the end of the text string.insertspsat the end of the regular expression.
ignore caseTreats uppercase and lowercase letters as the same. By default, the match is case sensitive.It does not change the regular expression. This option is equivalent to the standard "i" regular expression modifier.
multilinhaMatches multiple lines.It does not change the regular expression. This option is equivalent to the standard "m" regular expression modifier.

Usematch allequivalent to using the standard "g" regular expression modifier.

Syntax

EsMatch(Text,Get together[,options] )

  • Text- Necessary. The text string to test.
  • Get together- Necessary. The pattern to test as a string. Concatenate predefined patterns that theRolloenum defines or provides a regular expression.Get togethermust be a constant formula with no variables, data sources, or other dynamic references that change while the application is running.
  • options- Optional. A combination of text strings fromMatch Optionsenum values. Default,MatchOptions.CompleteIt is used.

Rollo(Text,Get together[,options] )

  • Text- Necessary. The text string to match.
  • Get together- Necessary. The pattern to match, as a text string. Concatenate predefined patterns that theRolloenum defines or provides a regular expression.Get togethermust be a constant formula with no variables, data sources, or other dynamic references that change while the application is running.
  • options- Optional. A combination of text strings fromMatch Optionsenum values. Default,MatchOptions.ContieneIt is used.

match all(Text,Get together[,options] )

  • Text- Necessary. The text string to match.
  • Get together- Necessary. The pattern to match, as a text string. Concatenate predefined patterns that theRolloenum defines or provides a regular expression.Get togethermust be a constant formula with no variables, data sources, or other dynamic references that change while the application is running.
  • options- Optional. A combination of text strings fromMatch Optionsenum values. Default,MatchOptions.ContieneIt is used.

IsMatch Examples

common characters

Imagine that your application contains atext inputdesignated controllertext input1. The user enters values ​​into this control to be stored in a database.

The user writesHello Worldnotext input1.

FormulaDescriptionResult
EsCoincidencia(TextInput1.Text, "Hola Welt")Checks that the user input exactly matches the string "Hello world".This right
IsMatch(TextInput1.Text, "Adeus")Tests that the user input exactly matches the string "Goodbye".INCORRECT
IsMatch(TextInput1.Text, "Hola", Contiene)Checks if the user input contains the word "hello" (it is case sensitive).INCORRECT
IsMatch(TextInput1.Text, "Hola", Contiene & IgnorarCase)Checks if the user input contains the word "hello" (it is not case sensitive).This right

predefined patterns

FormulaDescriptionResult
IsMatch( "123-45-7890", Digit & Digit & Digit & Hyphen & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit )Matches a US Social Security number.This right
IsMatch("joan@contoso.com", email)Matches an email addressThis right
IsMatch( "123.456", MultipleDigits & Period & OptionalDigits )Matches a string of digits, a period, and zero or more digits.This right
IsMatch("123", MultipleDigits & Period & OptionalDigits )Matches a string of digits, a period, and zero or more digits. No matching dots appear in the text, so this pattern does not match.INCORRECT

regular expressions

FormulaDescriptionResult
IsCoincidence("986", "\d+" )Matches an integer greater than zero.This right
EsCoincidence("1.02", "\d+(\.\d\d)?" )Corresponds to a positive monetary value. If the input contains a decimal point, the input must also contain two numeric characters after the decimal point. For example, 3.00 is valid, but 3.1 is not.This right
EsCoincidence( "-4.95", "(-)?\d+(\.\d\d)?" )Corresponds to a positive or negative monetary value. If the input contains a decimal point, the input must also contain two numeric characters after the decimal point.This right
EsCoincidence("111-11-1111", "\d{3}-\d{2}-\d{4}")Matches a US Social Security number. Validates the format, type, and length of the given input field. The string to be compared must consist of three numeric characters followed by a hyphen, then two numeric characters followed by a hyphen, and finally four numeric characters.This right
EsCoincidence("111-111-111", "\d{3}-\d{2}-\d{4}")Same as the previous example, but one of the hyphens is out of place in the input.INCORRECT
IsMatch( "ASstrongPasswordNot", "(?!^[0-9]\*$)(?!^[a-zA-Z]\*$)([a-zA-Z0-9]{8,10} )" )Validates a strong password that must contain eight, nine, or ten characters, plus at least one number and at least one letter. The string must not contain any special characters.INCORRECT

Examples of Match and MatchAll

FormulaDescriptionResult
Match( "Bob Jones <bob.jones@contoso.com>", "<(?<email>" & Match.Email & ")>"Extracts only the email portion of the contact information.{
Email: "bob.jones@contoso.com",
Full match:"<bob.jones@contoso.com>",
Submatches:["bob.jones@contoso.com"],
Starting game: 11
}
Match( "Bob Jones <Invalid Email>", "<(?<Email>" & Match.Email & ")>"Extracts only the email portion of the contact information. No valid address (no @ sign) found, so the function returnsArchive.Archive
Match( Language(), "(<Sprache>\w{2})(?:-(?<Script>\w{4}))?(?:-(?<Region>\w{2})) ?")Extracts the language, script, and region parts of the language tag containing theLanguageback function. These results reflect the United States; Watch theDocumentation of language functionfor more examples. He(?:The operator groups characters without creating another partial match.{
language: "en",
Script:Archive,
Region: "United States",
FullMatch: "es-ES",
Submatches: [ "in", "", "USA" ],
starting game: 1
}
Match( "PT2H1M39S", "PT(?:<hours>\d+)H)?(?:(?<minutes>\d+)M)?(?:(?<seconds>\d+)S)?" )Extracts the hours, minutes, and seconds from a permanent ISO 8601 value. The extracted numbers are still in a text string; use theWertFunction to convert it to a number before doing math on it.{
Hours: "2",
minutes: "1",
Seconds: "39",
Full match: "PT2H1M39S",
Partial matches:["2","1","39"],
starting game: 1
}

Let's take a look at the last example. If you want to convert this string to a date/time value usingTempofunction, you must pass the individually named submatches. you can use thecomfunction that in the record thatRolloReturns:

With( Match( "PT2H1M39S", "PT(?:(?<hours>\d+)H)?(?:(?<minutes>\d+)M)?(?:(?<seconds>\d+)S )?" ),time( value(hours), value(minutes), value(seconds)))

Add one to these examplesKnopfcontrol, adjustBy selectingproperty in this formula and then choose the button:

Set (pangram, "The agile brown fox jumps over the lazy dog").
FormulaDescriptionResult
Match(pangram, "EL", IgnoreCase )Find all matches of "THE" in the text string containing thepangramcontains the variable. The string contains two matches, but only the first one is returned because you are usingRolloand notmatch all. The Fuzzy Matches column is empty because no fuzzy matches are defined.{
Full Match: "Mother",
Partial matches: [],
Starting game: 32
}
MatchAll(pangram, "o" )Find all matches of "the" in the text string containing thepangramcontains the variable. The test is case sensitive, so only the second occurrence of "the" is found. The Fuzzy Matches column is empty because no fuzzy matches are defined.IsMatch, Match and MatchAll functions without Power Apps - Power Platform (1)
MatchAll(pangram, "o", IgnoreCase )Find all matches of "the" in the text string containing thepangramcontains the variable. In this case, the test is not case sensitive, so both instances of the word are found. The Fuzzy Matches column is empty because no fuzzy matches are defined.IsMatch, Match and MatchAll functions without Power Apps - Power Platform (2)
MatchAll(pangrama, "\b\wo\w\b" )Find the three letter words with an "o" in the middle. Note that "brown" has been removed because it is not a three-letter word and therefore does not match "\b" (word boundary).IsMatch, Match and MatchAll functions without Power Apps - Power Platform (3)
Partido( pangram, "\b\wo\w\b\s\*(?<zwischen>\w.+\w)\s\*\b\wo\w\b" )Matches all characters between "fox" and "dog".{
between: "skip laziness",
FullMatch: "Fox jumps over lazy dog",
SubMatches: ["jump over the slackers"],
Starting game: 17
}

to see the resultsmatch allin a gallery:

  1. On an empty canvas, add an empty verticalGalleryto control.

  2. set galleryArticleproperty forMatchAll(pangram, "\w+")oMatchAll (Pangram, MultipleLetters).

    IsMatch, Match and MatchAll functions without Power Apps - Power Platform (4)

  3. In the middle of the gallery control, select "Add an item from the Insert tab" to select the gallery template.

  4. add alabel- Control in gallery template.

  5. define labelsTextproperty forThis item.Full match.

    The gallery is full of all the words from our sample text. Resize the gallery template and tag control to fit all the words on one canvas.

    IsMatch, Match and MatchAll functions without Power Apps - Power Platform (5)

Opinion

Send and view feedback to

This productThis page

Top Articles
Latest Posts
Article information

Author: Prof. An Powlowski

Last Updated: 04/12/2023

Views: 5997

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Prof. An Powlowski

Birthday: 1992-09-29

Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

Phone: +26417467956738

Job: District Marketing Strategist

Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.