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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive