IsMatch, Match, and MatchAll functions in Power Apps - Power Platform (2024)

  • Article
  • 12 minutes to read

Tests for a match or extracts portions of a text string based on a pattern.

Description

The IsMatch function tests whether a text string matches a pattern that can comprise ordinary characters, predefined patterns, or a regular expression. The Match and MatchAll functions return what was matched, including sub-matches.

Use IsMatch to validate what a user has typed in a Text input control. For example, you can confirm whether the user has entered a valid email address before the result is saved to your data source. If the entry doesn't match your criteria, add other controls that prompt the user to correct the entry.

Use Match to extract the first text string that matches a pattern and MatchAll to extract all text strings that match. You can also extract sub-matches to parse complex strings.

Match returns a record of information for the first match found, and MatchAll returns a table of records for every match found. The record or records contain:

ColumnTypeDescription
named sub‑match or sub‑matchesTextEach named sub-match will have its own column. Create a named sub-match by using (?<name>...) in the regular expression. If a named sub-match has the same name as one of the predefined columns (below), the sub-match takes precedence, and a warning is generated. To avoid this warning, rename the sub-match.
FullMatchTextAll of the text string that was matched.
StartMatchNumberThe starting position of the match within the input text string. The first character of the string returns 1.
SubMatchesSingle-column table of Text (column Value)The table of named and unnamed sub-matches in the order in which they appear in the regular expression. Generally, named sub-matches are easier to work with and are encouraged. Use the ForAll function or Last( FirstN( ... ) ) functions to work with an individual sub-match. If no sub-matches are defined in the regular expression, this table will be present but empty.

These functions support MatchOptions. By default:

  • These functions perform a case-sensitive match. Use IgnoreCase to perform case-insensitive matches.
  • IsMatch matches the entire text string (Complete MatchOption), while Match and MatchAll search for a match anywhere in the text string (Contains MatchOption). Use Complete, Contains, BeginsWith, or EndsWith as appropriate for your scenario.

IsMatch returns true if the text string matches the pattern or false if it doesn't. Match returns blank if no match is found that can be tested with the IsBlank function. MatchAll returns an empty table if no match is found that can be tested with the IsEmpty function.

If you're using MatchAll to split a text string, consider using the Split function, which is simpler to use and faster.

Patterns

The key to using these functions is in describing the pattern to match. You describe the pattern in a text string as a combination of:

  • Ordinary characters, such as "abc" or "123".
  • Predefined patterns, such as Letter, MultipleDigits, or Email. (The Match enum defines these patterns.)
  • Regular-expression codes, such as "\d+\s+\d+" or "[a-z]+".

Combine these elements by using the . For example, "abc" & Digit & "\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 whitespace character.

Ordinary characters

The simplest pattern is a sequence of ordinary characters to be matched exactly.

For example, when used with the IsMatch function, the string "Hello" matches the pattern "Hello" exactly. No more and no less. The string "hello!" doesn't match the pattern because of the exclamation point on the end and because the case is wrong for the letter "h". (See MatchOptions for ways to modify this behavior.)

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

Special characterDescription
.dot or period
?question mark
*asterisk
+plus
( )parentheses
[ ]square brackets
{ }curly braces
^caret
$dollar sign
|vertical bar or pipe
\backslash

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

Predefined patterns

Predefined patterns provide a simple way to match either one of a set of characters or a sequence of multiple characters. Use the to combine your own text strings with members of the Match enum:

Match enumDescriptionRegular expression
AnyMatches any character..
CommaMatches a comma.,
DigitMatches a single digit ("0" through "9").\d
EmailMatches an email address that contains an "at" symbol ("@") and a domain name that contains a dot (".").+\@.+\\.[^\\.]{2,}
HyphenMatches a hyphen.\-
LeftParenMatches a left parenthesis "(".\(
LetterMatches a letter.\p{L}
MultipleDigitsMatches one or more digits.\d+
MultipleLettersMatches one or more letters.\p{L}+
MultipleNonSpacesMatches one or more characters that don't add whitespace (not space, tab, or newline).\S+
MultipleSpacesMatches one or more characters that add whitespace (space, tab, or newline).\s+
NonSpaceMatches a single character that doesn't add whitespace.\S
OptionalDigitsMatches zero, one, or more digits.\d*
OptionalLettersMatches zero, one, or more letters.\p{L}*
OptionalNonSpacesMatches zero, one, or more characters that don't add whitespace.\S*
OptionalSpacesMatches zero, one, or more characters that add whitespace.\s*
PeriodMatches a period or dot (".").\.
RightParenMatches a right parenthesis ")".\)
SpaceMatches a character that adds whitespace.\s
TabMatches a tab character.\t

For example, the pattern "A" & MultipleDigits will match the letter "A" followed by one or more digits.

Regular expressions

The pattern that these functions use is a regular expression. The ordinary characters and predefined patterns that are described earlier in this topic help build regular expressions.

Regular expressions are very powerful, available in many programming languages, and used for a wide variety of purposes. They can also often look like a random sequence of punctuation marks. This article doesn't describe all aspects of regular expressions, but a wealth of information, tutorials, and tools are available on the web.

Regular expressions come in different dialects, and Power Apps uses a variant of the JavaScript dialect. See regular-expression syntax for an introduction to the syntax. Named sub-matches (sometimes called named capture groups) are supported:

  • Named sub-matches: (?<name> ...)
  • Named backreferences: \k<name>

In the Match enum table earlier in this topic, each enum appears in the same row as its corresponding regular expression.

Match options

You can modify the behavior of these functions by specifying one or more options, which you can combine by using the string- concatenation operator (&).

MatchOptions enumDescriptionImpact on a regular expression
BeginsWithThe pattern must match from the beginning of the text.Adds a ^ to the start of the regular expression.
CompleteDefault for IsMatch. The pattern must match the entire string of text, from beginning to end.Adds a ^ to the start and a $ to the end of the regular expression.
ContainsDefault for Match and MatchAll. The pattern must appear somewhere in the text but doesn't need to begin or end it.Doesn't modify the regular expression.
EndsWithThe pattern must match the end of the string of text.Adds a $ to the end of the regular expression.
IgnoreCaseTreats uppercase and lowercase letters as identical. By default, matching is case sensitive.Doesn't modify the regular expression. This option is the equivalent of the standard "i" modifier for regular expressions.
MultilineMatches across multiple lines.Doesn't modify the regular expression. This option is the equivalent of the standard "m" modifier for regular expressions.

Using MatchAll is equivalent to using the standard "g" modifier for regular expressions.

Syntax

IsMatch( Text, Pattern [, Options ] )

  • Text – Required. The text string to test.
  • Pattern – Required. The pattern to test as a text string. Concatenate predefined patterns that the Match enum defines, or provide a regular expression. Pattern must be a constant formula without any variables, data sources, or other dynamic references that change as the app runs.
  • Options – Optional. A text-string combination of MatchOptions enum values. By default, MatchOptions.Complete is used.

Match( Text, Pattern [, Options ] )

  • Text – Required. The text string to match.
  • Pattern – Required. The pattern to match as a text string. Concatenate predefined patterns that the Match enum defines, or provide a regular expression. Pattern must be a constant formula without any variables, data sources, or other dynamic references that change as the app runs.
  • Options – Optional. A text-string combination of MatchOptions enum values. By default, MatchOptions.Contains is used.

MatchAll( Text, Pattern [, Options ] )

  • Text – Required. The text string to match.
  • Pattern – Required. The pattern to match as a text string. Concatenate predefined patterns that the Match enum defines, or provide a regular expression. Pattern must be a constant formula without any variables, data sources, or other dynamic references that change as the app runs.
  • Options – Optional. A text-string combination of MatchOptions enum values. By default, MatchOptions.Contains is used.

IsMatch examples

Ordinary characters

Imagine that your app contains a Text input control named TextInput1. The user enters values into this control to be stored in a database.

The user types Hello world into TextInput1.

FormulaDescriptionResult
IsMatch( TextInput1.Text, "Hello world" )Tests whether the user's input matches, exactly, the string "Hello world".true
IsMatch( TextInput1.Text, "Good bye" )Tests whether the user's input matches, exactly, the string "Good bye".false
IsMatch( TextInput1.Text, "hello", Contains )Tests whether the user's input contains the word "hello" (case sensitive).false
IsMatch( TextInput1.Text, "hello", Contains & IgnoreCase )Tests whether the user's input contains the word "hello" (case insensitive).true

Predefined patterns

FormulaDescriptionResult
IsMatch( "123-45-7890", Digit & Digit & Digit & Hyphen & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit )Matches a United States Social Security Numbertrue
IsMatch( "joan@contoso.com", Email )Matches an email addresstrue
IsMatch( "123.456", MultipleDigits & Period & OptionalDigits )Matches a sequence of digits, a period, and then zero or more digits.true
IsMatch( "123", MultipleDigits & Period & OptionalDigits )Matches a sequence of digits, a period, and then zero or more digits. A period doesn't appear in the text to match, so this pattern isn't matched.false

Regular expressions

FormulaDescriptionResult
IsMatch( "986", "\d+" )Matches an integer greater than zero.true
IsMatch( "1.02", "\d+(\.\d\d)?" )Matches a positive currency amount. 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 isn't.true
IsMatch( "-4.95", "(-)?\d+(\.\d\d)?" )Matches a positive or negative currency amount. If the input contains a decimal point, the input must also contain two numeric characters after the decimal point.true
IsMatch( "111-11-1111", "\d{3}-\d{2}-\d{4}" )Matches a United States Social Security number. Validates the format, type, and length of the supplied input field. The string to match must consist of three numeric characters followed by a dash, then two numeric characters followed by a dash, and then four numeric characters.true
IsMatch( "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.false
IsMatch( "AStrongPasswordNot", "(?!^[0-9]\*$)(?!^[a-zA-Z]\*$)([a-zA-Z0-9]{8,10})" )Validates a strong password, which must contain eight, nine, or 10 characters, in addition to at least one digit and at least one alphabetic character. The string must not contain special characters.false

Match and MatchAll examples

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",
FullMatch:"<bob.jones@contoso.com>",
SubMatches:["bob.jones@contoso.com"],
StartMatch: 11
}
Match( "Bob Jones <InvalidEmailAddress>", "<(?<email>" & Match.Email & ")>"Extracts only the email portion of the contact information. No legal address is found (there is no @ sign), so the function returns blank.blank
Match( Language(), "(<language>\w{2})(?:-(?<script>\w{4}))?(?:-(?<region>\w{2}))?" )Extracts the language, script, and region portions of the language tag that the Language function returns. These results reflect the United States; see the Language function documentation for more examples. The (?: operator groups characters without creating another sub-match.{
language: "en",
script: blank,
region: "US",
FullMatch: "en-US",
SubMatches: [ "en", "", "US" ],
StartMatch: 1
}
Match( "PT2H1M39S", "PT(?:<hours>\d+)H)?(?:(?<minutes>\d+)M)?(?:(?<seconds>\d+)S)?" )Extracts the hours, minutes, and seconds from an ISO 8601 duration value. The extracted numbers are still in a text string; use the Value function to convert it to a number before mathematical operations are performed on it.{
hours: "2",
minutes: "1",
seconds: "39",
FullMatch: "PT2H1M39S",
SubMatches:["2","1","39"],
StartMatch: 1
}

Let's drill into that last example. If you wanted to convert this string to a date/time value using the Time function, you must pass in the named sub-matches individually. To do this, you can use the With function operating on the record that Match returns:

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

For these examples, add a Button control, set its OnSelect property to this formula, and then select the button:

Set( pangram, "The quick brown fox jumps over the lazy dog." )
FormulaDescriptionResult
Match( pangram, "THE", IgnoreCase )Find all matches of "THE" in the text string that the pangram variable contains. The string contains two matches, but only the first is returned because you're using Match and not MatchAll. The SubMatches column is empty because no sub-matches were defined.{
FullMatch: "The",
SubMatches: [],
StartMatch: 32
}
MatchAll( pangram, "the" )Find all matches of "the" in the text string that the pangram variable contains. The test is case sensitive, so only the second instance of "the" is found. The SubMatches column is empty because no sub-matches were defined.IsMatch, Match, and MatchAll functions in Power Apps - Power Platform (1)
MatchAll( pangram, "the", IgnoreCase )Find all matches of "the" in the text string that the pangram variable contains. In this case, the test is case insensitive, so both instances of the word are found. The SubMatches column is empty because no sub-matches were defined.IsMatch, Match, and MatchAll functions in Power Apps - Power Platform (2)
MatchAll( pangram, "\b\wo\w\b" )Finds all three-letter words with an "o" in the middle. Note that "brown" is excluded because it's not a three-letter word and, therefore, fails to match "\b" (word boundary).IsMatch, Match, and MatchAll functions in Power Apps - Power Platform (3)
Match( pangram, "\b\wo\w\b\s\*(?<between>\w.+\w)\s\*\b\wo\w\b" )Matches all the characters between "fox" and "dog".{
between:"jumpsoverthelazy",
FullMatch:"foxjumpsoverthelazydog",
SubMatches: [ "jumps over the lazy" ],
StartMatch: 17
}

To see the results of MatchAll in a gallery:

  1. In an empty screen, insert a blank vertical Gallery control.

  2. Set the gallery's Items property to MatchAll( pangram, "\w+" ) or MatchAll( pangram, MultipleLetters ).

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

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

  4. Add a Label control to the gallery's template.

  5. Set the label's Text property to ThisItem.FullMatch.

    The gallery is filled with each word in our example text. Resize the gallery's template and the label control in order to see all the words on one screen.

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

Feedback

Submit and view feedback for

This product This page

IsMatch, Match, and MatchAll functions in Power Apps - Power Platform (2024)

FAQs

What are the different functions in PowerApps? ›

Substitute – Replaces part of a string with another string, by matching strings. SubmitForm – Saves the item in a form control to the data source. Sum – Calculates the sum of a table expression or a set of arguments. Switch – Matches with a set of values and then evaluates a corresponding formula.

What are the three core concepts of PowerApps? ›

In this article we are going to learn about creating Canvas App in PowerApp. On the first screen you can see there are 3 options: Canvas App, Model Driven and Portal.

How do I patch multiple records in PowerApps? ›

Use an extra label within the gallery
  1. Create an extra label within the gallery template. Bind it to the Id column. Rename the label to IdText.
  2. Remove the code on the OnCheck of the checkbox control mentioned above.
  3. Write the following formula on the OnSelect event of the Done Button: Power Apps Copy.
Dec 15, 2022

How do I convert text to numbers in PowerApps? ›

The Value function converts a string of text that contains number characters to a number value. Use this function when you need to perform calculations on numbers that were entered as text by a user.

What are the 6 major components of Power Apps? ›

Following are some of the main components in PowerApps.
  • Gallery: A gallery is one way to visualize data within the application. ...
  • Screen: It is a way to view a specific dataset or a record on the screens such as Desktop, iPad, mobile. ...
  • Card: A screen includes cards. ...
  • Control: ...
  • Property: ...
  • Function:

What are the 4 components of Power Platform? ›

Power platform has 4 primary components - Power BI, Power Apps, Power Automate and Power Virtual Agents. The other components that are often used with Power Platform are - Dataflex Pro (Common Data Services), AI Builder, and UI Flow (part of Automate).

What are the two types of Power Apps? ›

There are two main types of Power Apps: Canvas apps and Model-driven apps. Previously, Power Apps Portals would have fallen under this category. Microsoft have since released Power Pages, a standalone product that has evolved from the functionality of Power Apps Portals.

How many types of apps are there in Power Apps? ›

Using Power Apps, you can create Three types of apps: Canvas apps, Model-driven apps, and Portal Apps.

What is the fastest way to convert text to number? ›

Use Paste Special and Multiply

Select the cells that have numbers stored as text. On the Home tab, click Paste > Paste Special. Click Multiply, and then click OK. Excel multiplies each cell by 1, and in doing so, converts the text to numbers.

Can PowerApps send text message? ›

With PowerApps, we can generate text messages in a couple different ways: Using a Flow to send an automated message. Typically, this requires the use of a 3rd party action in Flow which will incur additional costs. Using the sender's own device to send the message through its native texting application.

How do I convert a table to a string in PowerApps? ›

Since the ID column is a number type, it needs to be converted into a string first, using the Text() function. “|”: This will add a pipe between the first column and the second column. Again, you can use any separator you want for this, just like the separator inside the Concat() function.

What is difference between Patch and submit in Power Apps? ›

With an Edit Form we use the SubmitForm function to save form data back to a SharePoint list. When building a Power Apps Patch Form our own form we must use the Patch function instead to submit data. The Patch function creates a new record or modifies an existing record in a datasource.

Which command is used for bulk Patch? ›

Patch(ChecklistItemsSource , CheckedItems)

Using ForAll and Patch: In many scenarios, the columns in source and destination tables vary and you cannot use the Patch statement, but instead use ForAll with Patch. With ForAll, you must loop through each record using a condition.

How do I update multiple rows at once? ›

There are a couple of ways to do it. INSERT INTO students (id, score1, score2) VALUES (1, 5, 8), (2, 10, 8), (3, 8, 3), (4, 10, 7) ON DUPLICATE KEY UPDATE score1 = VALUES(score1), score2 = VALUES(score2);

What are the two main types of components in an app *? ›

There are two main types of components: visible and non-visible. Visible components such as Button, TextBox, Label, etc. are part of the User Interface.

What are the 3 components of the power system? ›

The electrical power system consists of three major components: generation, a high voltage transmission grid, and a distribution system.

How many data sources are there in Power Apps? ›

The Dataverse gives PowerApps users access to three different storage areas, one for databases, one for logs and one for files.

What are the six 6 parts of the power supply? ›

Core Components of a Power Supply
  • The Transformer. The transformer is used to step the AC voltage up and down as well as provide isolation between the electronic system and the AC power. ...
  • The Rectifier. The rectifier is responsible for changing AC power to pulsating DC power. ...
  • The Filter. ...
  • The Regulator Circuits.

What are plugins in Power Platform? ›

A plug-in is a class within an assembly created using a . NET Framework Class library project using . NET Framework 4.6.

What are connectors in Power Platform? ›

A connector is a proxy or a wrapper around an API that allows the underlying service to talk to Microsoft Power Automate, Microsoft Power Apps, and Azure Logic Apps. It provides a way for users to connect their accounts and leverage a set of prebuilt actions and triggers to build their apps and workflows.

What are different DAX functions? ›

The DAX language uses four different types of calculation operators in formulas: Comparison operators to compare values and return a logical TRUE\FALSE value. Arithmetic operators to perform arithmetic calculations that return numeric values. Text concatenation operators to join two or more text strings.

What are functions in an app? ›

An app function can send users to a custom URL, send the iOS Push Registration message, or run another custom function you have set in your code. You'll generally use these immediately after a message or another action in a campaign. For example, you might have a message asking the user to update their profile.

Top Articles
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated:

Views: 6491

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.