Please tell me how can I extract emails (1st match) that does not contain words 'ajax' and 'gif' within email address. Here's the basic regex that I have:
match = re.findall('([\w.-]+#[\w.-]+\.\w+)', q.read(), re.I)[0]
Thanks,
I think you want something like this,
\b(?!\S*(?:ajax|gif)\S*)([\w.-]+#[\w.-]+\.\w+)\b
DEMO
Related
Lets say I have something like this:
vin#text.com
jay#text.com
text#text.com
All these id's belong to #text.com, and I want to match just that, whether an id has a
#text.com
or not
for example:
vin#gmail.com is invalid
while
vin#text.com is valid
but
vin#text.com.com , vin#text.com#text.com are both invalid
there should not be any characters after #text.com but there can be as many as possible in the beginning
So, text.com can be treated as required after # for your scenario.
Simple regex could be
^[a-zA-Z0-9+_.-]+#text.com+$
Please have a look if this works for you.
Happy Coding!
What I want to do is to validate an email address with exact gmail or yahoo word and I have tried the following but failed:
/^[a-z0-9._%+-]+#[^gmail$.-]+\.[a-z]{2,}$/
suppose if anyone mistakenly tried to sign up using example#gmal.com or example#mail.com or example#yaho.com or something like that. How can I validate that??
For regex to validate email you can refer this.
If you want a simple validator to allow only email addresses that contains #gmail as part of it and allow only letters,numbers,dot and underscores in user name, you can use below regex.
^[a-z0-9._]+#gmail\.[a-z]{2,}$
Demo
I have a registration form where email address is needed.
I need to allow the email addresses that belongs only to domain("NAME"#Mobily.com.sa) this is for employees that working for "MOBILY"
Also we need to disallow the emails that is ( "NAME".c#mobily.com.sa ) where those emails that ends up with (.c) belongs to the contractors working for "Mobily".
The Idea is to allow the employees and disallow the contractors from registration.
Please Advise the proper REGEX to achieve this.
Use this:
var regEx = /^(\w+)#(mobily\.com\.sa)$/i;
In case you want to support name as "abc.def", do
var regEx = /^(\w+\.?\w+)#(mobily\.com\.sa)$/i;
Examples:
regEx.test("ab212121c#mobily.com.sa") //true
regEx2.test("ab212121.c#mobily.com.sa") //false
The following regex can have a everything as name except names ending with .c
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+(?!\.c).{2}#mobily\.com\.sa$/i
See here
https://regex101.com/r/6vgQbj/2
You can use a negative lookahead to prevent .c from occurring right before the #.
/[\w\.\+-]+?(?!\.c).{2}#mobily\.com\.sa/g
See the regex in action here:
https://regex101.com/r/i0Rg34/2
please use this:
[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+#mobily.com.sa
I want to match the emails in following texts,
uma#cs.stanford.edu - match
uma at cs.Stanford.edu - match
http://infolab.stanford.edu/~widom/yearoff.h
we
genale.stanford.edu
n <A href="mailto:cheriton#cs.stanford.edu - match
hola # kirti.edu - match
Now I want to capture 2 parts of email address only like (uma) and (cs.stanford) in the email uma#cs.stanford.edu.
My current pattern is :
(\w+)[(\s+at\s+)|(\s*#\s*)]+(\w+|\w+\.\w+).edu
But it matches the string - infolab.stanford.edu - which I don't want.
Can anybody suggest any modification on this?
As long as you understand that this regex doesn't verify the correctness of your email address, but merely acts as a quick first line of defense against malformed addresses, an easy fix to your regex is as follows:
([\w.]+)(?:\s+at\s+|\s*#\s*)(\w+|\w+\.\w+).edu
In particular your regex was missing addresses with usernames containing . (which for example my main email address uses), as well as had a messed up middle part (pretending it's a character class and something weird about letting it repeat??). You can see the results here: http://refiddle.com/2js1
I'm currently using this very relaxed REGEX to validate email addresses:
(/(.+)#(.+)\.(.+){2,}/.test(emailAddress)
I believe that it only allows min1_allowsDots#min1_allowsDots.min2 - is this correct?
How should I modify it to match only a particular domain - anything# onlythisdomain.com?
TIA!
iSofia
(.+)#onlythisdomain\.(.+){2,}
This should do it.If .com is also fixed use
(.+)#onlythisdomain\.com
This simple RegEx basically says:
At least one character, then an "#", then literally "gmail.com".
If you change the domain to something else, it will not match.
var email = 'Godisgood#gmail.com';
var re = /.+\#gmail\.com/;
alert(email.match(re));
Maybe this could help you:
^[a-zA-Z0-9_.+-]+#(?:(?:[a-zA-Z0-9-]+\.)?[a-zA-Z]+\.)?
(company_domain1|company_domain2)\.ca$/g
It is a regex where you can validate the email including a specific domain such as
jhosh#doctorgroup.ca or jhosh#doctors.ca and it will match only if the email is ending with #doctorgroup.ca or #doctors.ca.