web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Regex Constants

(1) ShareShare
ReportReport
Posted on by 8
I'm working on a project that makes use of `IsMatch()` and it's related functions to validate and extract strings from user inputs; I've got to use the same RegEx in different formulas across the app. I would prefer to define one constant and use that in multiple places, so when I discover the RegEx needs to change, I just change the one constant instead of hunt down each formula I used it in edit them piecemeal (it's time-consuming and finnicky). However, I can't assign a value to `regex_pattern` via App.OnStart or All.Formulas because those are "variables" according to Power Apps, even if nothing in the app actually tries to change the value of `regex_pattern`!
 
How do I define a constant in Power Apps? How do I straight-up tell Power Apps "this means that?" I just want to set a value for `regex_pattern` on the editing-side, without any need to ever change its value while the app is running.
Categories:
I have the same question (0)
  • Suggested answer
    Pstork1 Profile Picture
    68,697 Most Valuable Professional on at
    Power Apps only has variables, not constants.  But what you could do that would make editing a little easier would be to use the search and replace function in the editor. That way you can search for all instances of the REGEX pattern and replace them at one time.  Here's a screenshot of a quick example.
     
    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    I have not tested this but since isMatch just returns a boolean can't you use named formulas and global variables to perform this functionality
    e,g. 
    IsMatch( "986", "\d+" ) Matches an integer greater than zero.
     
    I can create a global variable in OnStart 
    Set (integerCheck, "")
    and create a formula
    checkPositiveInteger=IsMatch(integerCheck,"\d+")
    when I want to check a value in my code I would then Set(integerCheck, myValue) and use checkPositiveInteger in my If statement
    All of your regex checks will then be expressed in one place as named formulas.
     
    I have no idea if this would work just a supposition.  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard