473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Email regular expression

Hello,

I have a regular expression to validate email addresses:
"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

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?

Thanks,
Miguel

Mar 14 '07 #1
3 2339
"\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:
MyDomain.Com
mydomain.com
MYDOMAIN.COM

Does not really matter

Thanks,
Miguel

Mar 14 '07 #3
A quick Google gives:

Options
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:

(?i:c)ool
(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
RegEx(pattern)
Another Regex constructor lets you set options:Dim re As New RegEx(pattern,
options)
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:
MyDomain.Com
mydomain.com
MYDOMAIN.COM

Does not really matter

Thanks,
Miguel

Mar 14 '07 #4

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

Similar topics

117
11897
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
5
3112
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
7
3831
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
25
5171
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
1
1952
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.
12
4868
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"; }
9
1899
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
10
30287
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...
5
1873
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
0
10456
Oralloy
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...
0
10230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
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...
1
7548
isladogs
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...
0
5442
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...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
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 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.