Regex - disallow www in email address [duplicate] - regex

This question already has answers here:
How can I validate an email address using a regular expression?
(79 answers)
Closed 5 years ago.
I am using a regular expression to validate email addresses in an online form. A lot of emails are entered as such: www.test#example.com
How can I disallow the use of www. using regex? My current expression:
^[\+_a-z0-9-'&=]+(\.[\+_a-z0-9-']+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$
I know this expression checks for a gTLD - we require an email address to have one.
EDIT: This question is slightly different to others I have found as I wasn't sure how to add the www exclusion in - that's all I needed.
Also, the target market we reach doesn't have the same experience using technology as most people do, so the amount of email addresses that we receive with www in them is massive. www.john#gmail.com is perfectly valid yes but it is 99% of the time not what the persons email address is. Our CRM system can't send emails to the correct people then.

you can use the regex
^(?!www\.)[\+_a-z0-9-'&=]+(\.[\+_a-z0-9-']+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$
see the regex demo

Related

Angular 6 email regex [duplicate]

This question already has answers here:
How can I validate an email address in JavaScript?
(79 answers)
Closed 4 years ago.
I want to validate all email inputs on my app with regex. But there is a problem, all the regex I have found allow emails with no TLD. I want a regex that can help me reject emails such as testing#testing,
Examples:
testing#testing.com should be valid
testing#testing.co.us should be valid
testing#testing should not be valid
The current regex I use is :
^([a-zA-Z0-9_-.]+)#(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$
But it accepts testing#testing for example, and that is not what I want.
How would I go about validating emails and rejecting ones without TLD
This is the regex which does what you want:
[A-Za-z0-9._%-]+#[A-Za-z0-9._%-]+\\.[a-z]{2,3}

Regular expression for an email address including .edu TLD [duplicate]

This question already has answers here:
How can I validate an email address using a regular expression?
(79 answers)
Closed 5 years ago.
I am writing a regular expression for checking valid email addresses.
"[A-Z0-9a-z._%+-]+#[A-Za-z0-9.-]+\.com"
How do I alter this to allow .edu and others?
Use | for Boolean "OR". You need to wrap the options in brackets, e.g. "Ben(jamin|edict)" means "Benjamin" or "Benedict", whereas "Benjamin|edict" means "Benjamin" or "edict".
"[A-Z0-9a-z._%+-]+#[A-Za-z0-9.-]+.(com|org|edu|net|gov|mil)"
Of course, this is failing to allow for country code top-level domains. It may be best to check if an email validation library exists for whatever programming language or framework you are using. E.g. Python has the validate_email module, PHP has FILTER_VALIDATE_EMAIL.

Regex to extract emails not working [duplicate]

This question already has answers here:
How can I validate an email address using a regular expression?
(79 answers)
Closed 7 years ago.
I am trying to extract all the email addresses from pages like this
http://www.quiltguilds.com/alabama.htm
I am using the following RegEX to extract all the emails.
\w+#\w*\.\w*
While this works at online Regex checkers, this isn't working with the import.io application where I am trying to use this to extract all emails.
Can someone kindly review the Regex and confirm if this one would work for extracting just email addresses from a block of text
Many thanks
You can use the following regex:
\S+\#\S+

Regular expression for complicated email [duplicate]

This question already has answers here:
How can I validate an email address using a regular expression?
(79 answers)
Closed 8 years ago.
I want an regex for email that starts with numbers and letters.
My regex is
/^[a-zA-Z0-9._-]+#[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/
What is wrong in this? It allows ._- from start and in between. But I don't want this
Valid emails = s#gmail.com, s.p#y.com, s_p123#g.com
Invalid emails = ....s#g.com, s---g#g.com, s...#g.com, 44s..p#g.com, ----s#g.com
Does anyone know how this can be done?
So you dont want to have more than one ._- in your regex? And also it shall not start with ._- Try it this way:
^[a-zA-Z0-9]+[._-]?[a-zA-Z0-9]*#[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}
It works for your examples, although im not really sure what email-syntax you really want to test for.
Perhaps you want to use one of many pre written examples in the web (just google ;) )

Regexp to find hostname and subdomain from email address [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Parse email addresses for “from” and “to” fields in Ruby
Given an email address of the form root#host.sub.domain.com, what is the regular expression to get the hostname and the subdomain as two individual variables? I mean $1='host'and $2='sub'?
You help is greatly appreciated :)
EDIT I should say I'm asking about a regular expression to do this, no Ruby code. This is to be used in a postfix configuration file, so I need a regexp. I mistakenly talked about Ruby earlier. My fault, sorry for the confusion.
Non-greedy groups are your friend. They match just what you need:
^(?:.*?)#(.*?)\.(.*?)\.(?:.*?)\.(?:.*?)$