473,725 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help understanding regular expression

Joe
Hi,

I have been using a regular expression that I don’t uite understand to
filter the valid email address. My regular expression is as follows:

<asp:RegularExp ressionValidato r id="valValidEma il"
runat="server"
ControlToValida te="txtEmail"

ValidationExpre ssion="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
ErrorMessage="I nvalid Email address."
Display="None">
</asp:RegularExpr essionValidator >

Can someone explain me why the email address jo*******@Z-5com.com is
considered an invalid email address?

Also can someone explain me what the above regular expression means?

Thanks,

Joe

Nov 19 '05 #1
3 2302
Hi Joe,

For an excellen regular expression resource pretaining to ASP.NET check
out http://RegExLib.com.

Try the following regular expression to help with e-mail address
validation:
http://regexlib.com/REDetails.aspx?regexp_id=284

Tod Birdsall, MCSD for .Net
http://tod1d.blogspot.com

Nov 19 '05 #2
the expression was written to be called with ignore case, but I'm not sure
you can pass the /i modifier to client script, so the capital Z fails.

explaining how complex regex expression works, is a bit beyond a newgroup
question. read about them, then ask about the part(s) you don't understand.
expect to spend several hours studying on it.

-- bruce (sqlwork.com)
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:D2******** *************** ***********@mic rosoft.com...
Hi,

I have been using a regular expression that I don't uite understand to
filter the valid email address. My regular expression is as follows:

<asp:RegularExp ressionValidato r id="valValidEma il"
runat="server"
ControlToValida te="txtEmail"

ValidationExpre ssion="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
ErrorMessage="I nvalid Email address."
Display="None">
</asp:RegularExpr essionValidator >

Can someone explain me why the email address jo*******@Z-5com.com is
considered an invalid email address?

Also can someone explain me what the above regular expression means?

Thanks,

Joe

Nov 19 '05 #3
Hi Joe,
Can someone explain me why the email address jo*******@Z-5com.com is
considered an invalid email address?
Thats easy. The regex doesn't match capital letter. The regex says that after
the @ symbol the following may occur :
([a-z0-9-]+)
With some imagination you can see what is ment by a-z. It means a or b or
c or d ... or z But it doesn't mean any capital.
If you change the above to
([a-zA-Z0-9-]+)
The email "oe.green@Z-5com" will match now.

But dont expect the improved regex to match every valid email now. The rules
that make up a valid email are complex and so is a corresponding regex that
tries to match every possible variation.
You can try regexes you find on the net or at http://RegExLib.com and see
if it does match your newly discovered anomaly.

But if you don't understand regexes and only copy paste them you will now
for sure have cases in wich the new regex doesnt match where the old regex
did.

The best way is to learn the essentials of regexes so you can diagones the
problem and make a small correction to the regex isntead of pasting a completly
new one.

Here are some resources if you have the time and intrest :

The short intro http://www.regular-expressions.info/
The tool http://www.regexbuddy.com/screen.html
The book Mastering Regular Expressions by Jeffrey Friedl (http://regex.info/
Also can someone explain me what the above regular expression means?
Thats harder because a regex conveys much information in a short line. In
general that regex says
- only match emails that are alone one a line with no surrounding text (^
and $ take care of this)
- Match letters and digits and - followed by a point and than some more
of the same
- match the @
- Match letters and digits and - followed by a point and than some more
of the same
- end with a text section thats 2 to 4 characters in lenght (.com is ok .commercial
is not)

If you read the intro at http://www.regular-expressions.info/ most of the
more subtle details will become apparant I hope.

Let me know if you have any more questions..

Cheers,
Tom Pester
Hi,

I have been using a regular expression that I don't uite understand to
filter the valid email address. My regular expression is as follows:

<asp:RegularExp ressionValidato r id="valValidEma il"
runat="server"
ControlToValida te="txtEmail"
ValidationExpre ssion="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a
-z0-9-]+)*(\.[a-z]{2,4})$"
ErrorMessage="I nvalid Email address."
Display="None">
</asp:RegularExpr essionValidator >
Can someone explain me why the email address jo*******@Z-5com.com is
considered an invalid email address?

Also can someone explain me what the above regular expression means?

Thanks,

Joe

Nov 19 '05 #4

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

Similar topics

2
2325
by: Joh | last post by:
Hello, (sorry long) i think i have missed something in the code below, i would like to design some kind of detector with python, but i feel totally in a no way now and need some advices to advance :( data = "it is an <atag> example of the kind of </atag> data it must handle and another kind of data".split(" ")
2
1814
by: Joe | last post by:
Hi, I have been using a regular expression that I don’t uite understand to filter the valid email address. My regular expression is as follows: <asp:RegularExpressionValidator id="valValidEmail" runat="server" ControlToValidate="txtEmail" ValidationExpression="^(+)(\.+)*@(+)(\.+)*(\.{2,4})$"
4
5157
by: Buddy | last post by:
Can someone please show me how to create a regular expression to do the following My text is set to MyColumn{1, 100} Test I want a regular expression that sets the text to the following testMyColumn{1, 100}Test Basically I want the regular expression to add the word test infront of the
18
3038
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How ??
3
278
by: moondaddy | last post by:
I need to rename file names with a specific naming convention which includes adding a SKU number at the end of the file name and I would like to use a regular expression to do this, but I don't even know where to start on this one. For example say my file name is MyFileName.jpg and my SKU number is 1234. I need to rename the file to MyFileName---1234.jpg where the sku number gets prefixed with "---". However, since there will be a...
18
2020
by: yawnmoth | last post by:
Say I have the following script: <? $string = 'test'; if (eregi("^+$",$string)) { echo 'matches!'; } else {
7
3828
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
3
1346
by: Lucky | last post by:
hi guys, i'm practising regular expression. i've got one string and i want it to split in groups. i was trying to make one regular expression but i didn't successed. please help me guys. i'm using .NET 2.0's Regular expression class. here is the string.
14
2270
by: Chris | last post by:
I need a pattern that matches a string that has the same number of '(' as ')': findall( compile('...'), '42^((2x+2)sin(x)) + (log(2)/log(5))' ) = Can anybody help me out? Thanks for any help!
0
8888
marktang
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...
0
9257
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
9174
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
9111
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
6011
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();...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
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
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.