cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
er
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
CarlosFigueira
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
CarlosFigueira
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (54,123)