Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Meaning of regular expressions

Posted on 2009-05-18
2
Medium Priority
?
300 Views
Last Modified: 2013-12-17
To all regexp expert out there, I'd like to request for insight of what following regexp would do (or at least how I can unravel it part-by-part). I understand it's trying to validate the inputStr, but I'm totally clueless as to what the pattern allows or doesn't allow. I'm regexp newbie, so a pattern this long is beyond my comprehension. All help is much appreciated.

string pattern = @"^(([^<>()[\]\\.,;:\s@\""]+"
      + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
      + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
      + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
      + @"[a-zA-Z]{2,}))$";
System.Text.RegularExpressions.Regex regExp = new System.Text.RegularExpressions.Regex(pattern);
if (!regExp.IsMatch(inputStr))
{
  //...
}

Open in new window

0
Comment
Question by:philipjonathan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
David S. earned 2000 total points
ID: 24418180
It's checking for valid email addresses.  It allows both IP addresses and domain names for the "domain part" of the address.  Also it doesn't overly restrict the "local part" of the address like many regexp validators that people write tend to do.

This is a great reference site for regexp: http://www.regular-expressions.info/tutorial.html
0
 
LVL 18

Author Comment

by:philipjonathan
ID: 24418401
Thanks Kravimir, both for the analysis and the great site. I managed to break down the regex with Expresso, and trying various email addresses on it. I'm playing around with it, and will post again for follow up. Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question