cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate IV
Advocate IV

Using IsMatch function with phone number?

Hello,

 

I would like to use the IsMatch function to make sure the phone number input in my form contains at least 7 digits. 

 

Here is the function I'm having trouble with: 

If(Len(DataCardValue11.Text)>=10, RGBA(130, 144, 156, 1), Color.DarkRed) & If(IsMatch(DataCardValue11.Text, \d{7}, Contains),RGBA(130, 144, 156, 1), Color.DarkRed)

 

Here are other functions that are working on the form: 

If(IsMatch(DataCardValue10.Text,Email),RGBA(130, 144, 156, 1), Color.DarkRed)

 

The error says that the problem is with the IsMatch function. I'm using it within Border Color. 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

The expression "\d{7}" requires that 7 digits be present in sequence, so a phone number like 555-1234 not match.

 

You may want to use something like the expression below, which requires the text to both have at least 10 characters, and have 3 digits, followed by an optional character, followed by 4 digits.

If(
    Len(DataCardValue11.Text)>=10 &&
        IsMatch(DataCardValue11.Text, "\d{3}.?\d{4}", MatchOptions.Contains),
    RGBA(130, 144, 156, 1),
    Color.DarkRed)

View solution in original post

1 REPLY 1
Highlighted
Power Apps
Power Apps

The expression "\d{7}" requires that 7 digits be present in sequence, so a phone number like 555-1234 not match.

 

You may want to use something like the expression below, which requires the text to both have at least 10 characters, and have 3 digits, followed by an optional character, followed by 4 digits.

If(
    Len(DataCardValue11.Text)>=10 &&
        IsMatch(DataCardValue11.Text, "\d{3}.?\d{4}", MatchOptions.Contains),
    RGBA(130, 144, 156, 1),
    Color.DarkRed)

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,990)