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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / IsMatch TextBox ; (Str...
Power Apps
Answered

IsMatch TextBox ; (String1 or String2)

(1) ShareShare
ReportReport
Posted on by 71

Hello ! 

 

I have a problem with the IsMatch function in my app.

 

What I'm trying to acheive is to force the user to respect a certain format when typing in a textbox like so : 2numbers, 1letter, 3numbers (e.g. 12A34).

 

My issue is that the letter has to specifically be either P or F, so I tried to force a choice with "Or", but Or only returns "false" and not one of the values. 

 

My code looks like this : (in OnChange of DataCardValue8)

 

If(
    IsMatch(
        DataCardValue8.Text;
        "\d{2}" & ("P" Or "F") & "\d{3}" ;
        MatchOptions.Complete
    );
    true;
    Notify(
        "Error";
        NotificationType.Error;
        15000
    );
    Reset(DataCardValue8)
)

 

If I only put either of the letters it works fine, so I don't know why it doesn't work when multiple values don't work.

 

Help is greatly appreciated, even if it's to tell me it's impossible etc...

 

Thanks !

prblm IsMatch.png
Categories:
  • Cre-do Profile Picture
    30 on at

    Hello!

     

    Try:

     

    If(
        IsMatch(
            DataCardValue8.Text;
            "\d{2}" & [a-zA-Z] & "\d{3}" ;
            MatchOptions.Complete
        );
        true;
        Notify(
            "Error";
            NotificationType.Error;
            15000
        );
        Reset(DataCardValue8)
    )

     

    [a-zA-Z] - defines range of letters.

  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Heya,

     

    You shouldn't mix regex with logic conditions as the IsMatch is looking for a regex string, just put the whole condition as a regex string - So in your case you want P or F characters which will be:

    "\d{2}[PF]\d{3}"

     

    Hope this helps!

     

    Cheers,

    Sancho

  • VJR Profile Picture
    7,635 on at

    Try this regex

    IsMatch(TextInput1.Text,"\d{2}(?:P|F)\d{3}")

  • adgkred Profile Picture
    228 on at

    Hey @Raph1, I'm more familiar with regex so I wrote it again in Regex, but this formula should work:

     

    IsMatch(
     DataCardValue8.Text,
     "^[0-9]{2}((P|F)){1}[0-9]{3}$",
     MatchOptions.Complete
    )

     

     

  • Verified answer
    Raph1 Profile Picture
    71 on at

    This worked as the easiest solution, thanks !

    "\d{2}" & "[PF]" & "\d{3}"

     

    (kept the "&"s for visibility)

     

    Thanks to everyone else who helped me with their answers too ! @Cre-do @VJR @adgkred 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard