I am well aware of what regular expressions are, so please avoid giving me definitions. I am merely looking for an opinion, and maybe even some advice. I am graduating soon with my degree in computer science, and to this point, The only education I have gotten on regular expressions, is through a course on PL design and development. We have never been educated on the actual application and use of it in programs that we are writing, only on using Regex to actually with the programming language.
The question I have is, am I right in assuming the regex is the most powerful tool in matching, and dealing with text? If I am wrong, what else is out there that I should be teaching myself (as opposed to becoming good with regex)? Also, does anybody know any good regex plugins for the Eclipse IDE(Galileo preferably). I’m looking for something that allows me to test the document and maybe highlight what is being done. Thanks
It is really depends on what does it means to be powerful.
In term of complexity, RegEx can hardly handle recursive, for example. You need something like Compiler Compiler (Compiler Generation) like JavaCC or YACC to handle that. This is the reason why you cannot easily create XML parser entirely from RegEx. The things is most of the time RegEx is sophisticate enough.
In term of performace, RegEx cannot compete with a direct parsing. For example, if you want to see if a string starts with the word “Prefix”; In RegEx you goes ‘
/^Prefix.*/‘ but in non-RegEx Java you goes ‘Str.startsWith("Prefix")‘. The speed of the two is incomparable.However, RegEx allows code to be a lot more manageable in many cases. The easiest example to see is that if you want to check if a string starts with atleast 10 numbers; In Java, you might write:
Compares to RegEx:
The code with RegEx is much more manageable.
What I am trying to say is that each technique has trade-ofs and they must be balance.
For most cases, RegEx is a very good tools for jobs it was designed to do.