Skip to main content

Notifications

Community site session details

Community site session details

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

how to identify chararcters from TextBox using RegEx

(0) ShareShare
ReportReport
Posted on 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 at
    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 at
    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 at
    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 at
    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

Announcing the Engage with the Community forum!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 94 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 72 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

Overall leaderboard