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 / how to identify charar...
Power Apps
Unanswered

how to identify chararcters from TextBox using RegEx

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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.

 

I have the same question (0)
  • Ben Thompson Profile Picture
    1,400 on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

    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.

  • cchannon Profile Picture
    4,702 Moderator on at

    @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 )

     

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
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard