Tamas Rudnai wrote: > 2009/5/25 Gerhard Fiedler > > >> I don't know that guy (do you?), but I know regexps -- and I know what >> he is talking about. A similar quote (don't know from whom) is -- >> paraphrased --: When all you know is a hammer, everything looks like a >> nail. Only after you learn how to properly use screwdrivers, wrenches of >> all sorts, and all the other nice tools around do you get a fuller >> picture. >> > > > I my experience all problems are coming when you use variables in regexp. To > tracking down in what circumstances the regexp does not work sometimes is > quite hard. Also to speed the process up is a bit of tedious job. > > Tamas > bahhhh. I love RegEx's... for all the wrong reasons, I am sure.... but, in general, regexes are used to solve problems that would otherwise take (many ..) multiple lines to program. The complexity of a RegEx is no greater than the equivalent code in whatever language. In other words, complex problems can have complex-looking solutions... whether those solutions are short 'confusing' regexes, or longer but convoluted 'traditional' code. The likelihood of a bug in one or the other approach is approximately equivalent (my opinion). On the other hand, it is much easier for a Regex competent person to put something in a regex than to do the same thing 'long-handed'... and also easier/quicker to maintain (but pity the person who needs to maintain a regex and does not know how they work ...). There are two issues I encounter when I deal with regexes.... 1. using them in places where they try to solve simple problems in complex ways.... like having 'OR' logic in a regex is often overkill... when simple if (regex1) else if (regex2) else ... blocks would suffice. Regexes are nice, but in my opinion they should not be used to implement program logic flow. Use them to process text... and leave program logic outside the regex. 2. They are near impossible to debug. Most languages allow you to trace or step through the program... but the regex engine is a huge black-box monstrosity that you can't debug. So, if there are regex problems it is hard to fix. Anyway, even if you could trace through the engine, you likelyy would not understand it anyway ;-) Breaking the regex in to multiple smaller steps is often the only way to solve this problem. Otherwise, RegExes are the holy grail of text processing. Rolf -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist