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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / how to identify charac...
Power Apps
Unanswered

how to identify characters from TextBox using RegEx

(0) ShareShare
ReportReport
Posted on by

Hi Mates

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

In shortly: When users enter alphabets in text box 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 text box in-between.

your help would be highly appreciated.

Categories:
I have the same question (0)
  • Verified answer
    SimonPiquer Profile Picture
    255 on at

    Hi,

     

    Have you tried this: 

     

    If(IsMatch(TextInput2.Text,Match.Letter,MatchOptions.Contains),Red,Green)
  • eka24 Profile Picture
    20,923 on at

    You can also try on the fill prpoerty:

    If(IsMatch(Textbox1.Text,"[a-z]+",Contains),Red,White)
    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
  • Community Power Platform Member Profile Picture
    on at

    Hi @SimonPiquer ,

    Really thanks for reply.

    Can you please elaborate a little bit more, because it seems little background work is there on Match.Letter and

    Match Options.Contains

    do i need to add/ create variable any ...? other wise how match.letter will capture only characters ..?

    please explain more what needs to be add any variable if required in which property.

    If(IsMatch(TextInput2.Text,Match.Letter,MatchOptions.Contains),Red,Green)

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @SimonPiquer 

    Great man its working as expected...

  • Community Power Platform Member Profile Picture
    on at

    Hi @eka24 

    Really great, your solution also working but i just tested with Simon reply  earlier and closed.

     

  • eka24 Profile Picture
    20,923 on at

    If it worked then mark as a solution as well. 

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • SimonPiquer Profile Picture
    255 on at

    Hi, Glad that it works!

     

    Documentation for IsMatch can be found here.

     

    To break it down:

     

    If(IsMatch(TextInput2.Text,Match.Letter,MatchOptions.Contains),Red,Green)

     

    Match.Letter means that it matches if there is a letter found, if you changed it to Match.Digit it would instead match if numbers were entered, you can also combine multiple criteria with an '&' to create a pattern to match. 

     

    MatchOptions.Contains means that it checks if the entered text contains the defined pattern. This can be exchanged with for example 'BeginsWith' or 'EndsWith' to make it check specific parts of the entered text. If you don't puta a MatchOptions in your formula it will check if the entire text matches your input text. 

  • Community Power Platform Member Profile Picture
    on at

    Hi @SimonPiquer 

    Thanks for explanation,

    actually i have two validations that is

    1. Character validation :  This is done.

    If(IsMatch(TextInput2.Text,Match.Letter,MatchOptions.Contains),Red,Blue)

    2.Special character validation. It should allow only (Dot,Comma,SemiColon, Colon) only in-between data like(40.50 or 40:50, or 40,50) but not all special characters.
    My Formula below for to alert if user enter special characters 

    If(Or(
    Find("*",TextInput1.Text)>0,
    Find("&",TextInput1.Text)>0,
    EndsWith(TextInput1.Text,"*")=true,
    EndsWith(TextInput1.Text,"&")=true),Red,Blue)

     I am sure this hard coding is not right way to but, don`t know how to alert on special characters here 

    Here i am hard coding with each and every special character actually.

    Condition on special character is 

    Not Allowed Special Character Symbols =(!`~@#$%^&*()_+")
    Allowed= (Dot, SemiColon, Colon,Comma)

    consecutive not allowed : **,%%,&&,((,))== etc

    Is there any code for Special characters as well ..?

     

    Kindly validate second condition validation as well.

  • SimonPiquer Profile Picture
    255 on at

    I guess you could do it this way if you really want to lock it down:

     

     

     

    If(IsMatch(TextInput2.Text,"\d{2}[;:.,]\d{2}" ),Green,Red)

     

     

     

    This changes it so that it matches text of the following format:

     

    \d{2} = 2 numeric digits

    [;:.,] = any of the characters within the brackets

    \d{2} = 2 numeric digits

     

    If you don't want to limit it to two digits before/after the symbol you can replace \d{2} with \d+

    Notice also I made Green the result for a true match here. 

  • Community Power Platform Member Profile Picture
    on at

    Hi @SimonPiquer 

    it seems like some what very close this issue

    \d+ works fine

    but as per update they also want to update negative values as well like 

    -20:20

    -20,-5

    etc..help me for allow negative values as well.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard