How to count numbers in an email address
I am trying to identify email address with more than 4 numbers occurring before @. I tried the following code
CASE
WHEN LENGTH(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
LEFT(Email, INSTR(Email, '@') - 1),
'a', ''), 'b', ''), 'c', ''), 'd', ''), 'e', ''),
'f', ''), 'g', ''), 'h', ''), 'i', ''), 'j', ''),
'k', ''), 'l', ''), 'm', ''), 'n', ''), 'o', ''),
'p', ''), 'q', ''), 'r', ''), 's', ''), 't', ''),
'u', ''), 'v', ''), 'w', ''), 'x', ''), 'y', ''), 'z', '')
) > 4
THEN 'More than 4 numbers before @'
ELSE '4 or fewer numbers before @'
END
but i keep getting syntax errors. Any thoughts on easier ways to do this? Appreciate all the help and thanks in advance.
Best Answer
-
Yeah! The best thing to do is split the email out so you only have characters left of the @ sign. Then remove all text and only keep numbers. Then count the characters left.
Use the following:
CHAR_LENGTH(REGEXP_REPLACE(SUBSTRING_INDEX(Email
, '@', 1),'[^0-9]+',''))Then use a case statement to filter out anything you don't want to count:
CASE WHEN `Left of @` < 4 THEN 'Less than 4' ELSE '4 or more' ENDIf I solved your problem, please select "yes" above
1
Answers
-
Yeah! The best thing to do is split the email out so you only have characters left of the @ sign. Then remove all text and only keep numbers. Then count the characters left.
Use the following:
CHAR_LENGTH(REGEXP_REPLACE(SUBSTRING_INDEX(Email
, '@', 1),'[^0-9]+',''))Then use a case statement to filter out anything you don't want to count:
CASE WHEN `Left of @` < 4 THEN 'Less than 4' ELSE '4 or more' ENDIf I solved your problem, please select "yes" above
1 -
That worked. Thanks Colemen.
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive