473,847 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Email regular expression


I have a regular expression to validate email addresses:

Now I need to force all emails to be from a given domain, for example,
accept only:
jo**@MyDomain.c om
an****@MyDomain .com
ma*******@MyDom ain.com

How should I changed by regular expression to accomplish this?


Mar 14 '07 #1
3 2342
"\w+([-+.]\w+)*@MyDomain\ .com" ?
Mar 14 '07 #2
On Mar 14, 2:20 pm, "Sergey Gorbachev" <SergeGo...@ram bler.ruwrote:
"\w+([-+.]\w+)*@MyDomain\ .com" ?
But I don't want MyDomain.com to be case sensitive.
Any variation would be accepted. for example:

Does not really matter


Mar 14 '07 #3
A quick Google gives:

Another approach to handling case insensitivity is to use the IgnoreCase
regex option. Options alter the overall regex matching behavior and, you
guessed it, IgnoreCase turns off regex's default case sensitivity. The
IgnoreCase option can be specified by prepending the short-form of the
option 'i' in a special construct at the beginning of the regex, like so:

(?i)coolThis inline syntax applies the option to an entire regex. However,
an alternative syntax allows you to apply an option to either the whole
expression or a subexpression:

(see http://www.ddj.com/dept/windows/184416603)Or you could try:Using the
Regex ClassAlmost anything you do with regular expressions in .NET starts
out by defining a Regex instance for the regular expression of interest,
like this (where pattern is your regular expression):Dim re As New
Another Regex constructor lets you set options:Dim re As New RegEx(pattern,
The available options are represented in the RegexOptions enumeration. The
options you are most likely to use are explained in Table 2. For the others
you can refer to the Visual Studio documentation. To set a single option,
pass it to the Regex constructor:Dim re As New RegEx(pattern,
RegexOptions.Ig noreCase)
To set two or more options, combine them with Or:Dim re As New
Regex(pattern, RegexOptions.Ig noreCase Or RegexOptions.Ri ghtToLeft)
Table 2. RegexOption members.Member Description IgnoreCase Specifies
case-insensitive matching. The default is case-sensititve ("a" does not
match "A", etc.). Multiline Multiline mode. The metacharacters ^ and $
will match the beginning and end, respectively, of any line and not just the
beginning and end of the entire input string (the default). RightToLeft
Specifies that the search will be performed right-to-left rather than the
default left-to-right. SingleLine Single line mode. Changes the meaning of
the period (.) metacharacter so that it matches any character including the
newline \n. By default it matches any character except the newline.
from:http://www.devsource.c om/article2/0,1895,2087373, 00.aspPeter"sha pper"
<md*****@gmail. comwrote in message
news:11******** *************@l 75g2000hse.goog legroups.com...
On Mar 14, 2:20 pm, "Sergey Gorbachev" <SergeGo...@ram bler.ruwrote:
> "\w+([-+.]\w+)*@MyDomain\ .com" ?

But I don't want MyDomain.com to be case sensitive.
Any variation would be accepted. for example:

Does not really matter


Mar 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
by: Ryan | last post by:
HELLO I am using the following MICROSOFT SUGGESTED (somewhere on msdn) regular expression to validate email addresses however I understand that the RFP allows for "+" symbols in the email address and this method does not.... Does anyone have an explanation? Function IsValidEmail(ByVal strIn As String) As Boolean
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I want to avoid that. My question here is if there is a way to pass either a memory stream or array of "find", "replace" expressions or any other way to avoid multiple copies of a string. Any help will be highly appreciated
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How do I gain access to the expression (not the matches) at runtime? Thanks, Mike
by: Jim Dornbush | last post by:
Has anyone seen an updated regex expression from Microsoft for the email validation expression so that single quotes are allowed? I've been using the canned regex for emails, but recently been informed by a customer that the single quote is allowed as part of the email address (Mr. O'Leary). I prefer using the un-modified version from the framework, but will update my local code regardless.
by: ll | last post by:
I am trying to finalize a regular expression in javascript to only allow emails with a certain domain to be valid. Here is what I have so far: var emailFilter2=/\@aol.com/; if(!(emailFilter2.test(strng))) { error = "Please enter a valid email address with the AOL domain.\n \n"; }
by: chadlupkes | last post by:
I have this code from someone else, and I'm trying to make heads or tails of it because IE doesn't like it. Can anyone help? Or does anyone have a better idea? /* parse the email to check for valid form */ function parseemail(str) { str = trim(str); <?if(preg_match("/MSIE 5.0;/", $_SERVER)) // this is IE 5.0
by: ll | last post by:
Hi, I currently am using the following regex in js for email validation, in which the email addresses can be separated by commas or semicolons. The problem, however, lies in that I can type two emails (as a run-on, with no comma or semicolon), and as long as it ends in a three character domain, it is accepted as valid. I wonder if there would be a way to make the comma or semicolon mandatory if a second email address existed? Many...
by: Ganesh | last post by:
Hi There, I need to validate email address with regular expression control, i tried something like this ^+*@*\.*$ but i need to validate even if it is blank, it should say invalid email, but don't want to use another requirefield validator
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.