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:
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:
"(ht|f)tp(s?)://[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(/?)([a-zA-Z0-9-.?,'/\+&%$#_]*)?"
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)
Upgrading to In Review, adding @LanceDelano and @GregLi who are looking at improvements in this area