tags:

views:

2954

answers:

8

I tried some regex tools like Regulator, Regulazy & RegexBuddy. They don't do what I want and they expect the user to know regular expressions.

I want a tool for dummies. You tell the tool I need a regex for something like "match anything that ends with the word 'yes' and it contains at least one occurrence of the phrase '/test/'" and it creates the regex for you.

So I either enter my request in plain English or semi plain English or the tool has all kinds of ready made selections and I choose between them to create what I want ad hoc.

Is there such a tool which is geared towards non developers? I am not looking for a regex tester.

+1  A: 

I am not sure such a tool exists, since they usually do the opposite:
Analyze a regexp and translate it in plain English.

The closest solution to your need would be this C# library, allowing you to program regexp in a semi-readable way:

Instead of this:

const string findGamesPattern = 
@"<div\s*class=""game""\s*id=""(?<gameID>\d+)-game""(?<content>.*?)<!--gameStatus\s*=\s*(?<gameState>\d+)-->";

You would have, using ReadableRex:

Pattern findGamesPattern = Pattern.With.Literal(@"<div")
    .WhiteSpace.Repeat.ZeroOrMore

    .Literal(@"class=""game""").WhiteSpace.Repeat.ZeroOrMore.Literal(@"id=""")

    .NamedGroup("gameId", Pattern.With.Digit.Repeat.OneOrMore)

    .Literal(@"-game""")

    .NamedGroup("content", Pattern.With.Anything.Repeat.Lazy.ZeroOrMore)

    .Literal(@"<!--gameStatus")

    .WhiteSpace.Repeat.ZeroOrMore.Literal("=").WhiteSpace.Repeat.ZeroOrMore

    .NamedGroup("gameState", Pattern.With.Digit.Repeat.OneOrMore)

    .Literal("-->");
VonC
Do you **really** find this readable? Is COBOL more readable than C, or just more verbose?
Jan Goyvaerts
@Jan: err... verbose. It is a poor form of self-documentation.
VonC
+2  A: 

txt2re seems really good. I entered "This string contains test in it and ends in yes" into the box, clicked on test and yes, and got a regular expression. It doesn't focus on teaching how to build regexes, but it shows you the perl code to parse what you need.

The real power of this tool is its ability to recognize things like dates, URLs, and tags. Whitespace didn't seem to work too well, however, and it doesn't appear to handle any sort of repetition.

jleedev
+1 Very cool. It even provides sample code to implement the regex in a variety of languages.
Mads Hansen
A: 

For me, the best tool is RegexBuilder it's open source and writen in C#, so you can customize it as much as you want ;)

Enjoy. ;)

Lukas Šalkauskas
-1: as specified by the author, he is "not looking for a regex tester"
VonC
+8  A: 

I have been a fan of Ultrapico's Expresso application. There is a builder section that helps you (a little) in building fragments of the expression. More importantly it will explain an existing expression (either your own or from the built in expression library) section by section.

It also includes a testing and replacement section to see and test your expressions. Lastly it will generate the expression formatted for either C#, C++, or VB.NET so that you know exactly how to insert the expression into your project.

Best of all it's free. I have been using this tool to help learn how regular expressions actually work, especially the complex ones. Can't say it makes writing expressions idiot proof but it has sure made learning expressions easier for me...

This tool was featured in a MSDN Webcast by Zain Naboulsi, and might be worth a watch. Hope this helps, and good luck with your Regex journey!

Dscoduc
Expresso is awesome. I use it for creating complex expressions in Python. The only thing you need to remember to do in that case is ass ?P<whatever> to your named groups.
Soviut
A: 

I was also using Expresso, and found it quite good. The most important thing for me in these tools is validation and not so much visual aids for building expressions. I only need a tool to kind of remind me things, not design them for me.

Anyway, here's another free one, which I quite like. It's called Rad Software Regular Expression Designer. Hope this helps.

Slavo
Yes, I agree. I was just trying to suggest an alternative, even if not directly useful, that I haven't created myself.
Slavo
+6  A: 

Personally I really like Expresso http://www.ultrapico.com/Expresso.htm The interface is quite clean - lets you test out search and replace functionality, has good help, plus it generates the C# expressions for you if you like.

paulecoyote
Hang on... for full disclosure here Jan creates a competiting product called "RegexBuddy" (see his own answer above). I recommended Expresso to a developer collegue just last week who knew nothing about regular expressions and found the builder very useful.While I appeciate you want to promote your own product, marking my answer down is very harsh. You could have just disagreed and pimped your product again.
paulecoyote
I agree with Paul! Paul's answer is good and fits here, so rating it down is not OK and promoting your commercial product via SO isn't too. BTW, I really like Expresso and use it very often for complex RegEx'.
Rene Schulte
A: 

If you are a mac person, try this widget, althought it's also a tester i find it quite useful as it's really easy to get to it while learning regex online

http://mac.softpedia.com/progDownload/Regex-Widget-Download-28467.html

cybervaldez
A: 

You may try http://www.regexcreator.com/demo.aspx , which lets you create regex from your sample inputs.. A downloadable beta version will be avaliable soon...