Solved

Generate Regex tool

Posted on 2011-09-28
5
402 Views
Last Modified: 2012-05-12
Hi Experts,

  In many times I need to work with Regex from simple to complex. I would like to know is there any free tool there to generate regex? I tried Regulazy but which is not given what I expected.

Say for example if I give text as easwaran.p@abc.com the Email regex should be given.

Any help is much appreciated. Thanks in advance.

Regards,
Easwaran.
0
Comment
Question by:Easwaran Paramasivam
[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
  • 3
5 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36716856
My guess is that deciphering what you want to match exactly (i.e. a literal string vs. a pattern) is a non-trivial task, which is why you don't see many such tools. You might try RegExr, which allows you to see real-time results as you type. You might at least get a feel for what particular regex constructs are doing if you see what they match for every change in your pattern.
0
 
LVL 4

Expert Comment

by:ricovox
ID: 36717349
There are several very nice tools for this.

The best one is probably RegexMagic, which costs $40  http://www.regexmagic.com/

Another tool that is great for designing and testing a regex is  RegexBuddy  http://www.regexbuddy.com/
0
 
LVL 4

Expert Comment

by:ricovox
ID: 36717442
Easwaran,

Your example is actually a bad one, because it is notoriously difficult to find a regex that will verify all valid email addresses. The reason is that the specification of "an email address" is actually very complex, once you start to consider all the possibilities. Here is some more info about that:

As an example, here is a regex that can verify 99.99% of all valid email addresses:
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b

As you can see, it is quite complicated. A simpler one (that matches only about 98-99% of all email addresses) is this one:  \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

You can of course find even simpler ones, but they either let in more invalid addresses or they exclude more valid ones. Both situations are bad.
0
 
LVL 4

Accepted Solution

by:
ricovox earned 500 total points
ID: 36717474
Here is a more detailed explanation about email address regex's:
http://www.regular-expressions.info/email.html

And here is a page that lists many common regex's:
http://www.regular-expressions.info/examples.html

Using a well-known regex that is already developed is really the best way to go. That way you know it is tested and you are not missing any scenarios.

If you try to do it the way you are currently attempting (e.g. by entering in an example text and having a program generate the regex) means you may be missing many possibilities that you won't think of for the examples.

But Good luck, and I hope it all works out for you!
0
 
LVL 16

Author Closing Comment

by:Easwaran Paramasivam
ID: 36812703
Thanks for your info.
0

Featured Post

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
need to convert function to c# 5 45
C# Formatting DateTime String Value 5 52
Need help with a query 14 40
c#, case, if 4 22
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

697 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