Solved

Generate Regex tool

Posted on 2011-09-28
5
398 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

10 Experts available now in Live!

Get 1:1 Help Now