T
Tom
I have struggled with the issue of whether or not to use Regular
Expressions for a long time now, and after implementing many text
manipulating solutions both ways, I've found that writing specialized
code instead of an RE is almost always the better solution. Here is
why....
RE's are complex. Sure it is one line of code, but it is on hell of a
line. Some of my RE remind me of the obfuscated code contest winners,
where one line of cryptic characters generates the 12 days of
Christmas. After you have worked out the complex RE it is almost
impossible for anyone(including yourself) to figure out what it is
really doing. Less code in not necessarily simple code. Plus it is not
like writing this "one line" of code is saving you any time. I have
had really complex RE's that took me hours to write that I needed
external tools to help me with. Sure it was only one line of code in
the end, but I could have written a page of easy to follow code in
half the time. Which brings me to my next point.
RE's are not debug-able. If I have a page of well written code I (or
anyone else) can easily step through it. When I send my 150 char RE
into the RE engine it is a black box. I am just left to wonder why it
didn't work.
Now I am sure you RE masters are out the just calling me a Dumb***,
Just learn REs better and you won't have any problems. But the reality
is that I can assume that anybody looking at my code is proficient in
C++/C#, because it is a C++/C# Program, I can't assume that they are a
RE Guru.
It's difficult to do some things in RE. RE's work great for some
search but not so well for others. I usually find myself having to get
a bunch of results back then doing some other processing on them get
the text out, which mean special code anyways.
Finally I don't know what you guy are saying about RE ever being
faster ever. In my experience RE's are slow, very slow. Like on the
order of 10 times slower then straight forward string parsing code.
For me this is the final kicker. Originally I went through all the
trouble off using RE's in all my complex text paring code because I
thought it would faster. This could be a result of .NET engine,
regardless I was really disappointed by this causing me to rollback a
lot of my solutions.
With all this said I still use REs sometimes, but only for really
simple string operations where I can come up with the expression in a
couple of seconds I don't care about performance and don't feel like
writing 5-10 lines of code. To me it is kind of like a quick hack.
Anyways that's my 2 bits.
Thomas
Expressions for a long time now, and after implementing many text
manipulating solutions both ways, I've found that writing specialized
code instead of an RE is almost always the better solution. Here is
why....
RE's are complex. Sure it is one line of code, but it is on hell of a
line. Some of my RE remind me of the obfuscated code contest winners,
where one line of cryptic characters generates the 12 days of
Christmas. After you have worked out the complex RE it is almost
impossible for anyone(including yourself) to figure out what it is
really doing. Less code in not necessarily simple code. Plus it is not
like writing this "one line" of code is saving you any time. I have
had really complex RE's that took me hours to write that I needed
external tools to help me with. Sure it was only one line of code in
the end, but I could have written a page of easy to follow code in
half the time. Which brings me to my next point.
RE's are not debug-able. If I have a page of well written code I (or
anyone else) can easily step through it. When I send my 150 char RE
into the RE engine it is a black box. I am just left to wonder why it
didn't work.
Now I am sure you RE masters are out the just calling me a Dumb***,
Just learn REs better and you won't have any problems. But the reality
is that I can assume that anybody looking at my code is proficient in
C++/C#, because it is a C++/C# Program, I can't assume that they are a
RE Guru.
It's difficult to do some things in RE. RE's work great for some
search but not so well for others. I usually find myself having to get
a bunch of results back then doing some other processing on them get
the text out, which mean special code anyways.
Finally I don't know what you guy are saying about RE ever being
faster ever. In my experience RE's are slow, very slow. Like on the
order of 10 times slower then straight forward string parsing code.
For me this is the final kicker. Originally I went through all the
trouble off using RE's in all my complex text paring code because I
thought it would faster. This could be a result of .NET engine,
regardless I was really disappointed by this causing me to rollback a
lot of my solutions.
With all this said I still use REs sometimes, but only for really
simple string operations where I can come up with the expression in a
couple of seconds I don't care about performance and don't feel like
writing 5-10 lines of code. To me it is kind of like a quick hack.
Anyways that's my 2 bits.
Thomas