how can I write #... email pattern , using regix [duplicate] - regex

This question already has answers here:
How can I validate an email address using a regular expression?
(79 answers)
Closed 2 years ago.
I want to validate an email field using regex in such a way that my email has to has #moore in it.
like a#moore.af, b#moore.sg, and so on. how can I write its pattern? I am using typescript and angular reactive form.
Your help is much appreciated.

You can try to use ([\w-\.]+#moore\.[\w+]{1,5}) to match an email address, as I left a 1-5 characters' space for the domain name.
In JavaScript flavour: const regex = /([\w-\.]+#moore\.[\w+]{1,5})/gm; then you can use regex.test(str) to validate the email field.
Edit:
As #Toto pointed out, This regex matches .....#moore.++++. Better regex would be:
([a-zA-Z0-9\.-]+#moore\.[a-zA-Z0-9\.]{1,5})
to only accept alphabet/number in the domain name.

Related

IIS URL Rewrite Match # in part of URL [duplicate]

This question already has answers here:
How does IIS URL Rewrite handle # anchor tags
(1 answer)
How to get Url Hash (#) from server side
(6 answers)
Closed 2 years ago.
I can't get IIS to match a URL with a #. Instead It trims the URL at the #
/product name to match #1.html
^seeds/([A-Za-z0-9-_ #]+).html/?$
I've tried escaping it, to no avail.
Result from IIS is /product name to match
Any ideas?
N.B. whoever marked my question as answered elsewhere please read my question again.

How to allow underscore in email regex in coldfusion [duplicate]

This question already has answers here:
How can I validate an email address in JavaScript?
(79 answers)
How can I validate an email address using a regular expression?
(79 answers)
Closed 4 years ago.
hi i am using the regex to validate the email but when i try to user underscore in email address than is giving me the error.
Following is regx which i am using.
^[a-zA-Z0-9-'+~]+(.[a-zA-Z0-9-'+~]+)*#([a-zA-Z_0-9-]+.)+[a-zA-Z]{2,10}$
if (not isValid("regex", arguments.propertyValue,"^[a-zA-Z0-9-'\+~]+(\.[a-zA-Z0-9-'\+~]+)*#([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,10}$")) {
}
can any one please let me know which regx should i use?

I am using Regex for email validation EMAIL_PATTERN:/^(\w+([.]\w+)*#\w+([.]\w+)*\.\w+([.]\w+)*)$/,

I'm Following the below Example:
Email validation expression \w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)* allows empty spaces
I'm using EMAIL_PATTERN:
`/^(\w+([.]\w+)*#\w+([.]\w+)*\.\w+([.]\w+)*)$/`
with minor changes.
It is allowing me to enter the email as i want but i dont want "_" at the
starting of the email address. Example: _abc#gmail.com
How to solve this?
What regex google is using in gmail?
Use This
/^([a-zA-Z0-9]+([.][a-zA-Z0-9]+)#\w+([.]\w+)\.\w+([.]\w+)*)$/,

Need a simple reg ex for url checking [duplicate]

This question already has answers here:
What is the best regular expression to check if a string is a valid URL?
(62 answers)
Closed 9 years ago.
I am looking for it about 2 hours, but can not find what I need.
what I need is very simple:
allow: google.com, http://google.com, https://google.com
disallow spaces "goo gle.com"
with a valid domain: I mean it should have a dot "." + any domain (.com, .net etc.)
and allow anything after that: "googl.com/dsfsdf/sdfs/blablahblah/" without spaces
thanks
Edit:
Thanks all, I had to write it myself.
if (!/^((ftp|http|https):\/\/)?([a-z0-9_\.-]+)\.{1}([a-z0-9_\/\?\=\-\%-]+)$/.test(uri)
|| /([\._\/\?\=\-\%-])\1/.test(uri)) {
}
ps: I am noob in regexs.
www.google.com
http://www.google.com
mailto:somebody#google.com
somebody#google.com
www.url-with-querystring.com/?url=has-querystring
The REGEX below matches all the above cases
((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+#)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+#)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%#.\w_]*)#?(?:[\w]*))?)
REGEX Explanation can be found here
Working Example
Something that's working for me on a production product (haven't received any complaints yet):
((www\.|(http|https|ftp|news|file)+\:\/\/)?[_.a-z0-9-]+\.[a-z0-9\/_:#=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])

Pcrepp - Perl Regular Expression syntax to match host name [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
The Hostname Regex
I'm trying to use pcrepp (PCRE) to extract hostname from url.
the pcre regular expression is as same as Perl 5 regular expression.
for example:
url = "http://www.pandora.com/#/volume/73";
// the match will be "http://www.pandora.com/".
I can't find the correct syntax of the regex for this example.
Needs to work for any url: amazon.com/sds/ should return: amazon.com.
or abebooks.co.uk/isbn="62345627457245"/blabla/ should return abebooks.co.uk
I don't need to check if the url is valid. just to get the hostname.
Something like this:
^(?:[a-z]+://)?[^/]+/?
See Regexp::Common::URI::http which uses sub-patterns defined in Regexp::Common::URI::RFC2396. Examining the source code of those modules should give you a good idea how to put together a decent pattern.
Here is one possibility:
^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$
And another:
^http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$
These and other URL related regular expressions can be found here: Regular Expression Library
string regex1, regex2, finalRegex;
regex1 = "^((\\w+):\\/\\/\\/?)?((\\w+):?(\\w+)?#)?([^\\/\\?:]+):?(\\d+)?(\\/?[^\\?#;\\|]+)?([;\\|])?([^\\?#]+)?\\??";
regex2 = "([^#]+)?#?(\\w*)";
//concatenation
finalRegex= regex1+regex2;
the result will be at the sixth place.
answered in another question I asked: Details.