Join the Alteryx Community’s Maveryx Summer Cup event! Compete, network with others, and earn your gold through a series of challenges from July 24th to August 11th. Learn more about the event here.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
解決済み

Email validation REGEX - Alteryx returning error - HELP

GavinAttard
ボリード

Hi Folks

 

I am using the following regex to validate email addresses: ([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})

 

IT works fine in a regex tester, but when i put it in Alteryx using the Regex_Match in a filter it returns the following error: 

 

Warning: Filter (16): REGEX_MATCH: RegEx: A character range was invalid, for example [d-a] at character 5

 

Any help trying to debug this would be greatly appreciated. 

 

cheers

 

Alteryx Everything, Leave no one behind.
8件の返信8
mborriero
ボリード

Why don't you use the Cleanse Macro?ValidateEmail.JPG

 

 

mborriero
ボリード

If you want to use regex, you can try o use this formula:

 

([\w\-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})

 

your problem was probably due to the "-" char.

GavinAttard
ボリード

Ahhhh... The 5 minutes after you post a help request, then solve the problem... 

 

ok so i isolated the problem to the the first capture group

 

([\w-\.]+)

 

Alteryx didn't like the \. - even though it is technically correct

 

The fix: Swap positions - ([\.\w-]+)

 

and it liked that....

 

so the full regex is now: ([\.\w-]+)@((?:[\w-]+\.)+)([a-zA-Z]{2,4})

 

ps, i also improved this to catch possible domains separated by '-'

 

Cheers 

Alteryx Everything, Leave no one behind.
GavinAttard
ボリード

Interesting looking macro.. don't seem to have that one... 

 

is that standard issue?

Alteryx Everything, Leave no one behind.
mborriero
ボリード

I believe it is a standard macro from version 10.6 or at least 11.0

 

If not, you can download it here:

 

https://community.alteryx.com/t5/Engine-Works-Blog/The-Cleanse-Macro/ba-p/2363

simonaubert_bd
パルサー

I tried this one and it works fine

 

 REGEX_MATCH([Email],"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"+"'"+"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"+"'"+")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])")

 

 

 

According to https://emailregex.com/, it's the RFC 5322 Officia Standard.

JophyJoy
アトム

How do you incorporate the changing special character acceptance in the local name across different domains? For example Gmail don't allow any special characters while hotmail can take - _ +. Seems bit complicated? Any easy way to solve this?

simonaubert_bd
パルサー

Hello @JophyJoy 

I would say : RFC 5322 Official Standard and nothing else.

ラベル