You are currently viewing Check if PowerApps Contains Substring
search for substrings in a string

Check if PowerApps Contains Substring

In this blog post, we will learn how to Check if string in PowerApps contains substring.

PowerApps Contains substring

In PowerApps, you can search for a substring (a part of a string) using many functions such as Find, IsMatch, In, exactin,…etc.

So let’s have some examples to check if a string contain substring in PowerApps using these functions.

Search for a substring using PowerApps ISMatch function

In PowerApps you can check if string contains substring or not using the IsMatch function.

  • Function Name: IsMatch
  • Purpose: The IsMatch function tests whether a text string matches a pattern that can comprise ordinary characters.
  • Syntax: IsMatch(String, Pattern,exint)
    • String: This is the string in which you want to search for the substring.
    • Pattern: This is the regular expression pattern that you want to match.
    • extent:This determine what part of the text we want to match, for example begin with, end with, contains, etc
  • Return: IsMatch function tests whether a string matches a regular expression pattern and returns a Boolean value .

Check if string contains another substring:

Examples:

IsMatch("Hello world", "world",MatchOptions.Contains)
PowerApps Contains
Search for substring using PowerApps IsMatch function

This formula will search for the substring “world” in the string “hello world” and it will return true because the substring was found in the string.

Also you can use the IsMatch function in validating user input based on a regular expression pattern as the following example will search for the substring devoworx in the string and if found it in any place, the formula will return true as this example

con3 | Power Platform Geeks
Search a string in PowerApps contains substring using IsMatch function with regular expression

check if PowerApps contains Substring using Find function

In PowerApps, you can also use the Find function to find a substring within another string.

  • Function Name: Find
  • Purpose: search for substring in string and return the starting position of the substring.
  • Syntax: Find(Substring, String [, Start])
    • Substring: This is the substring that you want to search for.
    • String: This is the string in which you want to search for the substring.
    • Start: This is an option starting position
  • Return: Find function tests whether a substring found in a string or not and returns the starting position of a substring and if not found it return blank.

Example

Find("dad","My dad")

The formula will return 4 the starting position of the substring.

You can use the Find function in a variety of scenarios, such as filtering a gallery or a data table based on a substring search. For example, you can use the Filter function with the Find function to filter a gallery based on a substring search:

Filter(Gallery, Find("Substring", MyColumn) > 0)

check if PowerApps contains Substring using in function

In PowerApps, you can also use the In function to check whether a string contains a substring or not. The In function returns a Boolean value indicating whether the substring was found in the string or not.

  • Name: in
  • Purpose: The In operator in PowerApps is used to check if a value is in a collection of values or in DataSource and you can use in operator to check if a user input matches one of several predefined values, or filtering a gallery or a data table based on a collection of values.
  • Syntax: Substring In String
    • Substring: This is the substring that you want to search for.
    • String: This is the string in which you want to search for the substring.
  • Return: The In operator returns a Boolean value that indicates whether a specified value is found in a collection/DataSource/string or not.

Example

"hello" in "hello world"

This formula will return true because the hello substring found in “hello world”

check if PowerApps contains Substring using exactin function

In PowerApps, the ExactIn operator is used to check whether a specified value is an exact match for any value in a collection/DataSource/String. The ExactIn operator returns a Boolean value that indicates whether the specified value is an exact match for any value in the collection/DataSource/String.

It is case sensitive

he exactin operator identifies matches only if they’re capitalized the same way

The following formula will return false because the h letter in the substring is Capital H and in the string is saml h.

"Hello" exactin "hello world"
con8 | Power Platform Geeks
con6 1 | Power Platform Geeks

Conclusion

In PowerApps, there are several functions that you can use to search for substrings in a string such as IsMatch, in, exactin and find.

See Also
Join us
Need Help
  • Have a related question? Please ask it at deBUG.to Community.

Heba Kamal

Microsoft MVP, MCT, Technical Speaker, Blogger, and Microsoft 365 and Power Platform Consultant.