cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
yashp1196
Frequent Visitor

Regex

In my text field, I only want alphabets, numbers, and commas

ex:

Test1,Test2,Test3

 

Exclude the followings:

!@#$%^&*()_-+={}[];:"'<>./?\|*+ also spaces, new lines, tabs

 

what is the regex for that? 

Ismatch(abc.text, provide regex)

2 REPLIES 2
BCLS776
Super User
Super User

It's not elegant, but it returns true for strings with only letters, numbers, or commas:

IsBlank(
    LookUp(
        ForAll(Split(TextInput2.Text,"") As aLetter,
            If(IsMatch(aLetter.Result,Digit) || IsMatch(aLetter.Result,Letter) || IsMatch(aLetter.Result,Comma), 
                {Value: "Yes"},
                {Value:"No"}
            )
        ), 
        Value = "No"
    )
)

You'll want to replace TextInput2.Text with your string reference.

 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
StalinPonnusamy
Super User
Super User

Hi @yashp1196 

 

I believe this can be shortened like

 

IsMatch(TextInput1.Text,"^[a-zA-Z0-9,]*$")

 

Negative

StalinPonnusamy_0-1633177802292.png

Positive

StalinPonnusamy_1-1633177821093.png

 

 

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (4,999)