Solved

Regular Expressions

Posted on 2013-05-12
8
509 Views
Last Modified: 2013-05-15
Hello,
I would like to know what you use for a Regular Expression tool?  I'm not asking about an editor, but some type of "expression test tool."  I can google for such app, and read;
http://www.bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html
http://www.bastian-bergerhoff.com/eclipse/features/web/QuickREx/standalone.html#why

Yet allow me to ask; is there a better tool, or the best tool?
0
Comment
Question by:chima
8 Comments
 
LVL 9

Assisted Solution

by:user_n
user_n earned 75 total points
Comment Utility
Regular expresions are diferent for diferent programing languages
0
 

Author Comment

by:chima
Comment Utility
user_n, really! now that's a pain.  Okay, for Python then.
0
 
LVL 28

Expert Comment

by:pepr
Comment Utility
Regular expressions are the way of expressing programs that accept the tested strings. They are a kind of programs where the code (the pattern string) is compiled into the form of so called automaton. This way, one can think also of regular languages See the Noam Chomski hierarchy and the basics of formal grammars (http://en.wikipedia.org/wiki/Chomsky_hierarchy).

From that perspective, it is difficult to think about a general tool that would test your regular expression.

However, you can use the approach used for testing programs. Simply said, you can create the set of strings that will be used for testing of your regular expression. The testing function will produce the boolean result that says whether the regular expression behaves the expected way.

When the approach is used for testing the functionality of fragments of bigger code (of the functions, procedures), it is called unit testing (http://en.wikipedia.org/wiki/Unit_testing). When you define the wanted behaviour in the form of tests first, and only then you start to implement the solution, then the approach is called test-driven development (http://en.wikipedia.org/wiki/Test_driven_development).

To summarize, you may want to use the unit test framework that is available in Python as the standard module (http://docs.python.org/2/library/unittest.html).

There is the chapter in "Dive Into Python 3" explicitly focused to creating the regular expressions (http://getpython3.com/diveintopython3/regular-expressions.html), and a separate chapter is devoted to unit testing -- shown on testing the regular expressions built in the earlier chapter (http://getpython3.com/diveintopython3/unit-testing.html). The book itself is nicely written, not using big words, explaining what you need to know.
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 50 total points
Comment Utility
Regular expressions are the way of expressing programs that accept the tested strings
Not really, regular expressions express the set of strings the set of strings to be accepted, but say nothing about the program that accepts them.
There can be many different algorithms for accepting the set of strings specified by a regular expression, and many different programs implementing those algorithms.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 28

Expert Comment

by:pepr
Comment Utility
@ozo: There is the data/code duality when programming. The strings expressed via regular expressions can only be accepted by some program that implements the detection, right? The implementations may differ, but should not we start from the basics? And the efficient implementation is based on a final automaton.
0
 

Author Comment

by:chima
Comment Utility
pepr and ozo, while I appreciate your comments, and some good knowledge became of your comments, I feel that we got off the question.  I was/am in search of other Regular Expression tools like QuickREx, see initial links given.  My question is; are there other tools which are better than QuickREx?  Or at least one?
i did not know that Regular Expressions were not a "standard."  User_n pointed out that there are ; "Regular expresions are diferent for diferent programing languages."
I googled to learn whether QuickREx could work with Python and it can.
The purpose of this question, is to learn whether I should spend the time to study QuickREx, when in fact there is a better tool than QuickREx.
0
 
LVL 28

Accepted Solution

by:
pepr earned 375 total points
Comment Utility
It depends. If you use Eclipse as your Python IDE (e.g. http://www.vogella.com/articles/Python/article.html), then using QuickREx may be the good choice. If you do not use Eclipse, then it can be a complication for you.

It also depends on what you mean by the expression test tool. For testing a single expression with several sentences, you can use a separate Python script that simply prints the result. If you want to have the collection of tests that check whether the development of the regular expression patterns did not break the previous functionality, then the QuickREx will not help you that much.

You cannot build a regular expression if you do not understand what it really does (or estimate what it should do, in advance). The trial/failure approach would take too much time. I personally would choose a separate, simple Python script or the unittest approach for more extensive testing.
0
 

Author Closing Comment

by:chima
Comment Utility
thanks for the help.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 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

17 Experts available now in Live!

Get 1:1 Help Now