Skip to main content
Community site session details

Community site session details

Session Id : B6seam02MgmRjGvMNG43t/
Power Apps - Power Apps Pro Dev & ISV
Unanswered

how to identify chararcters from TextBox using RegEx

Like (0) ShareShare
ReportReport
Posted on 8 Jun 2020 08:05:44 by

Hi Mates

Is there any experts on Reg-Ex to identify characters/string from textbox

In shortly: When users enter alphabets in textbox then identify to alert or set border RED color to understand them invalid

Example : valid cases are below

20:30

40;30

50.60

but not 20:30abc  or   abc20:30 or 20:abc

when user enter alphabets then it should alert.

If(IsMatch(TextInput2.Text,"^[?!A-Za-z]*$"),Red,Green)

as of  using above code but, its not alerting when users enter characters in textbox in-between.

your help would be highly apricated.

 

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on 08 Jun 2020 at 16:15:15
    Re: how to identify chararcters from TextBox using RegEx

    @ben-thompson is correct that [a-z][A-Z] will get you any capital or lowercase letter in the latin alphabet, but it is also worth pointing out that the simpler regex pattern:

     

    \p{L}

     

    is also a shorthand for <any letter> and encompasses non-standard letter characters.

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-ismatch#predefined-patterns 

     

    I would also point out that you can use the Contains operator to specify a match anywhere in the string without needing to make a more elaborate regex:

    IsMatch( TextInput1.Text, "\p{L}", Contains )

     

  • Ben Thompson Profile Picture
    1,400 on 08 Jun 2020 at 09:18:34
    Re: how to identify chararcters from TextBox using RegEx

    The one thing I missed from the regex site is that the site automatically added a global flag which I missed.

     

    [a-zA-Z]/g is what you should be using.

  • Community Power Platform Member Profile Picture
    on 08 Jun 2020 at 09:12:57
    Re: how to identify chararcters from TextBox using RegEx

    Hi @ben-thompson 

    Really thanks for reply,

    On top of that I just added *$ now its working if more than 0 characters fine, but now issue is how to find and validate in between letters

    ex. if user enter 123abc then it should trigger but the given formula is not throwing between characters. 

    If(IsMatch(TextInput2.Text,"[a-zA-Z]*$"),Red,Green)

    Help for if found any characters in whole text box ..?

  • Ben Thompson Profile Picture
    1,400 on 08 Jun 2020 at 08:17:52
    Re: how to identify chararcters from TextBox using RegEx

    My advice when it comes to regex is to always use a regex editor to create your Regular expression the first one that comes up on Google is https://regex101.com/ and it seems to work fine.

     

    And don't forget that you can reverse true and false if it makes the query easier which I suspect is the case in your example. 

     

    [a-zA-Z] will return true if a letter is within the string and false if the format matches the correct format so 

     

    If(IsMatch(TextInput2.Text,"[a-zA-Z]/g"),Green,Red) or If(!IsMatch(TextInput2.Text,"[a-zA-Z]/g"),Red,Green) should work for you.

     

    Edit added the global /g flag I didn't notice had been added by the regex site first time around.

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Loading complete