03-11-2011, 11:58 PM
Lines of code are not the only measure of a solution. Accuracy, flexibility, ease of understanding are important as well. Regular expressions are great for dealing with ambiguity in data. Regular expressions are quite flexible and can match many variations on a data "theme". However, regular expressions often do not do as well in the "ease of understanding" area as other solutions, and, as you pointed out, they may not be as efficient as other solutions.
We run our test sets overnight, unattended. For us, speed of execution is secondary. What does the poster plan to do with the data once it is parsed? Write it to another file? That is much, much slower than the regular expression and so the regular expression is a smaller percentage of the total execution time.
I am not arguing that a regular expression is the best or only solution here, but it is a good solution if the data format is varied as the examples suggest. If the data is NOT as varied as the examples suggest (i.e., there are typos in the example), then a regular expression would be overkill - like bringing in the USS Enterprise to kill a mouse.
It does provide more information to the poster about ways to tackle the problem and, hopefully, expands the poster's knowledge of QTP a little.
We run our test sets overnight, unattended. For us, speed of execution is secondary. What does the poster plan to do with the data once it is parsed? Write it to another file? That is much, much slower than the regular expression and so the regular expression is a smaller percentage of the total execution time.
I am not arguing that a regular expression is the best or only solution here, but it is a good solution if the data format is varied as the examples suggest. If the data is NOT as varied as the examples suggest (i.e., there are typos in the example), then a regular expression would be overkill - like bringing in the USS Enterprise to kill a mouse.
It does provide more information to the poster about ways to tackle the problem and, hopefully, expands the poster's knowledge of QTP a little.