Showing results for 
Search instead for 
Did you mean: 

IsMatch() show allow for variable (not constant) regular expressions

IsMatch() should allow the ability to use a variable (global and context) for the Pattern parameter (2nd) that contains the regular expression pattern.   Currently IsMatch() function requires the regular expression (2nd parameter) to be a constant value (literal string).


ie: the request is that the below should be permissible:


Set( URL_MATCH, "(ht|f)tp(s?)://[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(/?)([a-zA-Z0-9-.?,'/\+&%$#_]*)?" );

Set( IsUrl, IsMatch( TextInput1.Text, URL_MATCH ) )

(Note the forum here converts part of the regular expression in the code section above into a frown face, whereas that section really should be a colon : followed by a left paren ( - the expression I attempted to put here is the same in IsMatch() for identifying a URL)


Currently, this results in the error:


   The function 'IsMatch' has some invalid arguments.

   Regular expressions must be constant values.


Why must this be constant?  Seems that this is an unnecessary limitation.


Issues with this approach (requiring these to be constant) include:


  1. Inability to define the RegEx expresions in a single place in the code (setting in a global variable) and use throughout the application (probably issue #1 overall with PowerApps is limitations on code reuse and having to duplicate unnecessarily code).  Currently I have to copy IsMatch() expressions throughout my code with the SAME literal string everywhere (of course this could be helped if we had Macro support in PowerApps...)"

  2. Inability to read RegEx expressions from an external source - ie: assume the requirement is to allow the expression to be changed external to the application, and the application (on startup) read these in.  This is a realistic requirement.


Please consider modifying IsMatch() to allow the "Pattern" parameter to be a string.  


Note that since PowerApps does not have true definable constants, the only way to do this is with a literal string, ie: 


which does not promote code reusability - and thus the only way to use IsMatch() is with a literal string.


However, even with support for true contants or macros - neither of which are available in PowerApps (which may be one way to address #1), issue #2 is still not addressed.  


Allowing for a variable to be used for Pattern would not only promote code reusability to some degree (#1 - since I could just set my patterns in variables early in the code like in OnStart()), but also allow for much more maintainable applications and more flexibility and address #2.


BTW - also note that the documentation does NOT address this limitation of IsMatch() (ie: that Pattern must be a constant)

Status: Under Review

Upgrading to In Review, adding @LanceDelano and @GregLi who are looking at improvements in this area

Power Apps
Power Apps
Status changed to: Under Review

Upgrading to In Review, adding @LanceDelano and @GregLi who are looking at improvements in this area

Advocate II

Perhaps to add onto this.
I know you can add url query parameters when launching the app and reference them via


As those query parameters cannot change without needing to reload the app any variables referenced via that method should be considered constants.

Not applicable
Any update? This would come in VERY handy right now.
Helper I

Is there any work around for this? I’m trying to recognise text from ocr api. 

Regular Visitor

This idea feels like a no-brainer. We're entering the pattern as a string anyway; there's no reason it shouldn't be able to be passed in from a function or variable.

Not applicable

BTW - another approach (though I'd prefer still being able to do a real/modifiable string) would be to provide a Constant variable type, perhaps something like this:


Define( myConstant, "abcdefg" )


Then, myConstant would not be allowed to change values, and thus could be allowed to function as an input for IsMatch(), Match(), and MatchAll().


And thus you define the constant once, and can use throughout the app.  Idea is that the "constant" would have Global scope (like a global variable with Set()).


Note that there are lots of other reasons to want true constants.  I'll submit another idea specifically for this when I get a chance.


Regular Visitor

Hey everyone, I came across the same issue when I was trying to determine whether the selectedtext.value was in another listbox.


In my own app I was able to get around this limitation by using the Find function and comparing its result with the Blank() function to generate the true/false result.


Instead of: If(Ismatch(EnabledOptionsList, FullOptionsList.SelectedText.Value, Contains), true_value, else_value)

This worked: 

If(Find(FullOptionsList.SelectedText.Value, EnabledOptionsList) = Blank(), true_value, else_value)


Where EnabledOptionsList is a string (app variable I defined as "Option1|Option2|Option3" delimited by "|")


Hope this helps somebody!

Helper I

This feature has been under review for nearly 2 years now, and requested extensively for 4 years. 


Why is this really sort-after feature not getting the attention it needs?!

Frequent Visitor

Hello @Anonymous , @adoyle5 , @Mannyman , @Zimos , @asafweis 


I have this error "Regular expressions must be constant" the second time I use IsMatch formula. 


In the first place I entered is working perfectly, but when I used it into another field it showed me this error. Can you please help me understand?


Thank you,


Regular Visitor



Can you share the syntax you are using that is triggering the error?