Re: Search for multiple things in a string
- From: "Oliver Sturm" <oliver@xxxxxxxxxxxx>
- Date: Thu, 15 Sep 2005 09:46:20 +0100
Jon Skeet [C# MVP] wrote:
In a hurry, I can very easily see someone changing a string literal from one thing to another, not noticing that as it's a regular expression, they need to escape part of their new string.
In a hurry, all kinds of things can happen when making changes to source code.
Now, where's the advantage of using regular expressions in this case?
I wasn't saying there was one in the specific scenario the OP introduced. I was using the example to show that regular expressions don't have to be any more complicated than simple string operations.
About IndexOf, as I meant to say already, as long as the problems you're trying to solve are the kind that can be solved with those simple string functions (and without resulting in huge algorithms), you'll probably have the performance argument on your side anyway.
Well, I'm much keener on the readability argument than the performance one - I suspect that the performance difference would rarely be of overall significance.
As I'm trying to say all the time, as soon as an implementation reaches a complexity that makes it worth thinking about regular expressions, I'm sure an alternative solution based on simple string functions won't be more readable any longer. I'd even go so far as to say that as soon as more than one call to a simple string function is needed for a given problem, most probably I'll find the regular expression solution more readable. This is, after all, a subjective decision to make.
Oliver Sturm -- Expert programming and consulting services available See http://www.sturmnet.org (try /blog as well) .
- References:
- Search for multiple things in a string
- From: tshad
- Re: Search for multiple things in a string
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Search for multiple things in a string
- From: tshad
- Re: Search for multiple things in a string
- From: Jon Skeet [C# MVP]
- Re: Search for multiple things in a string
- From: Oliver Sturm
- Re: Search for multiple things in a string
- From: Jon Skeet [C# MVP]
- Search for multiple things in a string
- Prev by Date: Re: implicit types in C# 3.0, what is the usefulness of them?
- Next by Date: Re: Problem when executing batch file with HelloWorld.exe %1
- Previous by thread: Re: Search for multiple things in a string
- Next by thread: Re: Search for multiple things in a string
- Index(es):
Relevant Pages
|
Loading