Format Integer Data to Get ONLY 10 Digits for a Phone Number

Hi All,

I have an excel sheet with a column of “PhoneNumber” with different formats of phone numbers. I am trying to format the column so that all numbers have same pattern.

Column looks like this

Phone Number

398-555-0132
1 (11) 500 555-0132
577-555-0185
417-555-0154
129-555-0195
346-555-0124
629-555-0159
1 (11) 500 555-0153
592-555-0166

Expected Output

3985550132
5005550132
5775550185
4175550154
1295550195
3465550124
6295550159
5005550153
5925550166

My Requirements are

  • Only 10 digits should be entered in the column

  • No Spaces, No Dash “-”, No parenthesis " () "

  • The number can start with any digit [1-9], except 0.

  • Can contain any numbers in the last 9 digits.

I tried using regex, didn’t worked

UiPath Forum Search

Any advice please!

Happy Automation :slight_smile:

Hi @Zeba,

Start with regex to extract the values

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

OR 

\d+(-|\s)\d+-\d+

From regex101 so we know the expressions works


This expression is not universal, it can only parse your sample input string / phone numbers as posted in the question.

In Studio, you can either use string.Replace or regex to replace the spaces or hyphens from your matches

I am sure you can add any additional logic as you now know how this can be achieved.

Here is the sample .xaml file : FormatPhoneNumbers.xaml (10.7 KB)

Hope this helps you!