CRM Crate

How to match a text value using Power FX functions in Canvas Apps?

We will learn to match a text value using IsMatch, Match, and MatchAll functions in Canvas Apps. Before we start, make sure to subscribe to CRM Crate to that you can stay up to date in the field of Power Platform.

 match a text in Canvas App

What is Power FX?

Microsoft’s Power Fx is the low-code language that will be used across Power Platform. It’s a strong-typed, general-purpose, declarative, and functional programming language. Power Fx is expressed in user-friendly text. It’s a low-code language that citizen developers & makers can work with directly in an Excel-like formula bar or Visual Studio Code text window.

It enables a complete range of development from no-code for those who have never programmed before to “pro-code” for the seasoned professional, with no learning or rewriting cliffs in between, enabling diverse teams to collaborate and save time and expense.


Understanding IsMatch(), Match(), MatchAll() function to match a text in Canvas App

IsMatch ()

The IsMatch function tests whether a text string matches a pattern that can comprise ordinary characters, predefined patterns, or a regular expression.
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.

Match() & MatchAll()

The Match and MatchAll functions return what was matched, including sub-matches. 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.

Understanding different patterns available in Matching functions

  • The main component used in these functions is in stating the pattern to match. We can describe the pattern in a text or a string as combination of:
    – Predefined patterns, such as EmailMultipleDigits, or Letter
    – Regular-expression codes, such as “\d+\s+\d+” or “[a-z]+”.
    – Ordinary characters, such as “crm” or “123”.

List of available Ordinary Patterns:

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

Example of IsMatch() function with Ordinary Patterns:

FormulaDescriptionResult
IsMatch( TextInput.Text, "CRM Crate" )Tests whether the user’s input matches, exactly, the string “CRM Crate”.true
IsMatch( TextInput.Text, "Prashant irlotkar" )Tests whether the user’s input matches, exactly, the string “Prashant Tirlotkar”.false
IsMatch( TextInput.Text, "CRM", Contains )Tests whether the user’s input contains the word “CRM” (case sensitive).false
IsMatch( TextInput.Text, "CRM", Contains & IgnoreCase )Tests whether the user’s input contains the word “CRM” (case insensitive).true

List of available Predefined Patterns:

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

Example of IsMatch() function with 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

Validate the implementation of IsMatch() function in Canvas App

The below animation describes the working of IsMatch() function in Canvas App.

match a text canvas app

Thus, we learned to match a text value using Power FX functions in Canvas Apps.


5 1 vote
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!

Congratulations!

Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.