Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 1uTv9qVk2cdatyBMZgCfGO
Power Apps - Building Power Apps
Answered

IsMatch - Match Regular Expression with Dynamic Pattern stored in data source table for Gallery

Like (0) ShareShare
ReportReport
Posted on 6 Oct 2023 14:53:41 by 11

Hi,
I am trying to match the dynamic Regular Expression pattern in PowerApps Gallery Control. My Gallery Control data source table contains the RegEx pattern column to be matched with textbox in same gallery control. But when I am using ThisItem object for pattern in IsMatch, it is not allowing in formula.
Example-
IsMatch(txtbox.value,ThisItem.RegEx) - Not allowing ThisItem.RegEx as allowed pattern is constant/enum string only.

Any way to Match dynamic RegEx pattern stored in table with textbox in gallery?

  • Verified answer
    PrashantParkale Profile Picture
    11 on 09 Oct 2023 at 11:06:19
    Re: IsMatch - Match Regular Expression with Dynamic Pattern stored in data source table for Gallery

    Thanks for reply.
     figured out the way and noted down in blog-
    http://mscrm16tech.com/2023/10/09/dynamic-regular-expression-regex-pattern-match-using-ismatch-match-in-powerapps/

  • Geeks_D Profile Picture
    1,169 on 06 Oct 2023 at 17:53:33
    Re: IsMatch - Match Regular Expression with Dynamic Pattern stored in data source table for Gallery

    Hi 

    Okay I think I have a clue of what you are trying to achieve here, for this, I do not think u really need to use a Regex Stored in on the data source to achieve this, you can have a label that checks for data validation for each control inside your gallery and hard code your Regex function with a if statement to achieve this 
    Here is a PowerFx Snippet to achieve this : 

    If( //Condtional Statement
     CountIf( //If Statement
     Split( //Split each string into substrings
     TextInput1.Text, //TextInputControl in your Gallery
     "" //Splitting value
     ),
     Not( //Condition Expression
     IsMatch( //Match Function
     Value, //Condition Value
     "([A-Za-z0-9])" //RegexExpression 
     )
     )
     ) > 0, //Condition
     "Wrong Character in text" //DisplayText
    )

    Outside your Gallery, you can have a label that check all the validation label for any errors in your Data Input 

     

  • PrashantParkale Profile Picture
    11 on 06 Oct 2023 at 15:38:58
    Re: IsMatch - Match Regular Expression with Dynamic Pattern stored in data source table for Gallery

    Hi,

    I have Gallery control which shows dynamic statements and capturing response from user in textbox in gallery for respective statement. Each statement expecting the response in particular format like email, date, number, phone number,etc. So I am storing relevant regular expression for each statement in same table. That regEx I want to match with user response and validate before saving it.

    I want to match these dynamic regEx and looking for the solution to it.

  • Geeks_D Profile Picture
    1,169 on 06 Oct 2023 at 15:08:12
    Re: IsMatch - Match Regular Expression with Dynamic Pattern stored in data source table for Gallery

    Hi 
    The isMatch function tries to match a pattern that can comprise of ordinary character or a predefined pattern, ThisItem.Regex is a record value from a DataSource and is not a constant 
    You will need to hardcode your Regex Expression into your PowerFx 
    A brief explanation of what you are trying to achieve will be helpful 

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started