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
Solved

Generate Regex tool

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

837 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