Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

To check if a phone number is in (xxx)-xxx-xxxx format

sucansa
7 - Meteor

Hi,

 

I am new to Alteryx.. I have a use case to check if the phone number is 10 or 11 digits then it should be in (xxx)-xxx-xxxx format. If it is, make the result "Pass", else "Fail". I am not sure how to achieve this.  can someone help on this?

3 REPLIES 3
NickSm
Alteryx
Alteryx

Hey @sucansa 

 

This could be a case for the RegEx tool and the "Match" function.  Can determine a pattern - in this case:

 

\(\d{3}\)-\d{3}-\d{4}

 

Which looks for 3 digits in parentheses, 3 digits, then 4 digits all separated by the dash.  If a match is found it outputs "True", else "False". You could modify this a bit if you also wanted to check for a potential 11th digit.

 

regex_Match.JPG

 

 

Sample workflow attached

 

 

Treyson
13 - Pulsar
13 - Pulsar

Just to clarify, are you asking to find a series of numbers that are either 10 or 11 digits that you need to format like (XXX) XXX-XXXX?

 

or

 

Are you looking for (XXX) XXX-XXXX where they are all numbers?

Treyson Marks
Managing Partner
DCG Analytics
TomWelgemoed
12 - Quasar

Hi Sucansa,

 

This is a Regex task - which is complicated for many of us!

 

I've had to Google this myself, but looks like the expression you're looking for is:

^(1\s?)?((\([0-9]{3}\))|[0-9]{3})[\s\-]?[\0-9]{3}[\s\-]?[0-9]{4}$

 

All you have to do is paste this in a Regex tool, choose the output as "Match" and the Regex will validate the format. I'm attaching a packaged workflow as an example for you.

 

Regards,
Tom

 

 

Labels
Top Solution Authors