Best Of
REGEX Tutorial to Validate US Phone Numbers
Hi everyone,
I wanted to create this discussion post to share a methodology I created using Domo's Regular Expressions in Magic ETL to parse and validate US phone numbers. This validation process follows the basic standards set by the North American Numbering Plan (NANP) and helps identify valid US phone numbers from a dataset using just a small reference table and just a few ETL tiles and formulas.
Valid US Phone Number Parsing Tutorial:
- Create a US Area Codes reference table: Simply upload the attached spreadsheet (or copy and paste the data into a Domo webform) that contains a current list of valid US area codes.
- Add a Formula tile and create an Area Code field using the following formula: LEFT(TRIM(REGEXP_REPLACE(`Phone Number`, '[^0-9]', '')),3)
- Join the US Area Codes reference table to your main dataset that using the Area Code as the join key. To resolve the duplicate field names, simply rename the reference table field to Valid Area Code.
- In another Formula tile, create a Valid Area Code? flag using the following formula: IFNULL(`Valid Area Code`,'Invalid')
- Create another formula called Valid Phone Number? underneath the "Valid Area Code?" flag:
CASE
WHEN `Valid Area Code?` = 'Invalid' THEN 'FALSE'
WHEN REGEXP_LIKE(TRIM(REGEXP_REPLACE(`Phone Number`, '[^0-9]', '')), '^(?:[2-9][0-9]{2}){2}[0-9]{4}$')
AND NOT REGEXP_LIKE(TRIM(REGEXP_REPLACE(`Phone Number`, '[^0-9]', '')), '^(.)\1{9}$')
AND NOT REGEXP_LIKE(TRIM(REGEXP_REPLACE(`Phone Number`, '[^0-9]', '')), '^[0-9]{3}911[0-9]{4}$')
AND NOT REGEXP_LIKE(TRIM(REGEXP_REPLACE(`Phone Number`, '[^0-9]', '')), '^[2-9][0-9]{2}555[0-9]{4}$')
THEN 'TRUE'
ELSE 'FALSE'
END
The formula above checks the following information for each phone number:
- The number contains exactly 10 numerical digits with a valid structure defined by the North American Numbering Plan (NANP): (NPA) NXX-XXXX.
- The number's area code (NPA) and prefix (NXX) both start with digits 2-9.
- The number is not composed entirely of the same digit (e.g., 1111111111).
- The number does not contain the "911" sequence in the prefix (NXX) position.
- The number does not contain the "555" sequence in the prefix (NXX) position.
I hope this is helpful for anyone working with large datasets of phone numbers who need to filter out invalid US phone numbers! Please feel free to provide any feedback to further optimize or expand on this logic, especially if anyone has patterns for international formats or any additional edge cases I may have missed.
Thank you!
Re: How do I add a Field to the 'Card Title' or 'Description' even if it is not a card filter?
@brycec LISTAGG is a new one for me, thank you! I played with it, and it also works with DISTINCT, so I'll add that to your suggestion:
REPLACE(LISTAGG(DISTINCT `Current Pages), ',', ', ')
Re: How do I add a Field to the 'Card Title' or 'Description' even if it is not a card filter?
Oh, great point @DavidChurchman! Even better, there is a way to add all those Current Pages to the Summary Number. Simply use the LISTAGG(`Current Pages`) and you should be set! There is no way to adjust the LISTAGG separator, but you could just do REPLACE(LISTAGG(`Current Pages`), ',', ', ') to change it to have a space after the comma or you can adjust that Beast Mode accordingly to have any separator you want.
brycec
Re: Comment out tiles in MagicETL
Commenting to bump this and hope that it gets renewed interest. @AndreaHenderson now that we have sections, the ability to comment those out and/or hide them would be awesome.
Cutting the Strings in updated MagicETL?
I don't seem to be able to cut the strings between tiles in MagicETL anymore. Anyone else seeing this?
Update: I closed and re-opened the ETL and was able to cut strings again.
Re: Extract data from Image or PDFs using Domo AI
Yeah, we could process and parse images from S3, SFTP, etc…
We've also got some new stuff getting announced tomorrow that will be an unlock here…
Re: Area Chart 2025-2028
You need to reshape your data so the years are in a column. That would be easy in a MagicETL:
Re: Bar Chart 2025-2028
With the 4 columns you describe (Product, 2025, …, 2028), I don't think there's a way to get the bar chart you described without reshaping your data first. The only card I can think of that would analyze your data as is would be the pivot table:
If you're willing to do a quick MagicETL to unpivot your data to a long format, then it's very easy to get what you described:
Re: Pagination issue with JSON No Code Connector (API PennyLane)
Hello ggenovese,
This method worked very well, thank you for your help!
Re: Hello from a new Domosapien in Melbourne, Australia
Hi Brian, great to have you in the community!








