Solved

Generate Regex tool

Posted on 2011-09-28
5
389 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
  • 3
5 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your info.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now