Latest Posts

PowerApps check whether string matches pattern


The IsMatch function in PowerApps is used to check whether a text string matches a specified pattern. This function is particularly useful for validating user input, ensuring data consistency, and performing text pattern matching.

PowerApps – IsMatch() Syntax

 

 

IsMatch(Text, Pattern [, Options [, MatchOptions]])

 

  • Text: The text string to be tested.
  • Pattern: The pattern to match against the text. This can be a string or a regular expression.
  • Options: (Optional) A set of options to control the behavior of the pattern matching. For example, IgnoreCase to make the match case-insensitive.
  • MatchOptions: (Optional) Specifies how to apply the pattern. For example, Complete (default) to match the entire text, Contains to check if the pattern is found within the text, or StartsWith to check if the text starts with the pattern.

PowerApps – IsMatch() basic Example

To check if a text string matches a simple pattern:

 

IsMatch("hello", "hello")

This returns true because the text "hello" matches the pattern "hello".

PowerApps – check if the values match using a Regular Expression

To check if a text string is a valid email address:

 

IsMatch("[email protected]", "^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$")

This uses a regular expression to validate the email format and returns true if the text matches the pattern.

PowerApps – perform Case-Insensitive Match

To perform a case-insensitive match:

 

 

IsMatch("Hello", "hello", IgnoreCase)

This returns true because the match is case-insensitive.

PowerApps – match specific pattern in string

To check if a text string contains a specific pattern:

 

IsMatch("PowerApps is great", "great", Contains)

This returns true because the text "PowerApps is great" contains the word "great".

PowerApps - Validate Email Addresses

To validate that a user's input is a valid email address in a text input control:

 

 

If(IsMatch(TextInput1.Text, "^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"), "Valid Email", "Invalid Email")

This checks if the text input matches the email pattern and displays "Valid Email" or "Invalid Email" accordingly.

PowerApps – Ensure Input value is numeric

To ensure that a text input contains only numeric characters:

 

IsMatch(TextInput1.Text, "^\d+$")

This returns true if the text input contains only digits.

PowerApps - Check Phone Number Format

To validate that a phone number follows a specific format (e.g., (123) 456-7890):

 

 

IsMatch(TextInput1.Text, "^\(\d{3}\) \d{3}-\d{4}$")

This checks if the phone number matches the specified pattern.


We value your Feedback:

Page URL:

Name:

Email:


Suggestion:

© 2024 Code SharePoint