Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Email regular expression

Reply
Thread Tools

Email regular expression

 
 
shapper
Guest
Posts: n/a
 
      03-14-2007
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:



....

How should I changed by regular expression to accomplish this?

Thanks,
Miguel

 
Reply With Quote
 
 
 
 
Sergey Gorbachev
Guest
Posts: n/a
 
      03-14-2007
"\w+([-+.]\w+)*@MyDomain\.com" ?


 
Reply With Quote
 
 
 
 
shapper
Guest
Posts: n/a
 
      03-14-2007
On Mar 14, 2:20 pm, "Sergey Gorbachev" <SergeGo...@rambler.ru> wrote:
> "\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

 
Reply With Quote
 
Peter Bradley
Guest
Posts: n/a
 
      03-14-2007
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)im re As New
RegEx(pattern)
Another Regex constructor lets you set optionsim 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 constructorim re As New RegEx(pattern,
RegexOptions.IgnoreCase)
To set two or more options, combine them with Orim re As New
Regex(pattern, RegexOptions.IgnoreCase Or RegexOptions.RightToLeft)
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.com/article2/0,1895,2087373,00.aspPeter"shapper"
<> wrote in message
news: ups.com...
> On Mar 14, 2:20 pm, "Sergey Gorbachev" <SergeGo...@rambler.ru> wrote:
>> "\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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57