From: Tony Johansson on 10 Mar 2010 11:31 Hi! I just wonder when is it better to use regular(Regex) expression then to use substring ? //Tony
From: Harlan Messinger on 10 Mar 2010 11:43 Tony Johansson wrote: > Hi! > > I just wonder when is it better to use regular(Regex) expression then to use > substring ? The only time it's better to use a regular expression than substring is when substring isn't applicable--that is, when what you're trying to match isn't a fixed string. You wouldn't bother with a regular expression just to find out if a string contains the substring "foo" somewhere inside it.
From: Tony Johansson on 10 Mar 2010 16:13 "Harlan Messinger" <hmessinger.removethis(a)comcast.net> skrev i meddelandet news:7vq0hfFh73U1(a)mid.individual.net... > Tony Johansson wrote: >> Hi! >> >> I just wonder when is it better to use regular(Regex) expression then to >> use substring ? > > The only time it's better to use a regular expression than substring is > when substring isn't applicable--that is, when what you're trying to match > isn't a fixed string. You wouldn't bother with a regular expression just > to find out if a string contains the substring "foo" somewhere inside it. If I just ask in general when should I use regular expression instead of doing the same thing with classes //Tony
From: Harlan Messinger on 10 Mar 2010 17:01 Tony Johansson wrote: > "Harlan Messinger" <hmessinger.removethis(a)comcast.net> skrev i meddelandet > news:7vq0hfFh73U1(a)mid.individual.net... >> Tony Johansson wrote: >>> Hi! >>> >>> I just wonder when is it better to use regular(Regex) expression then to >>> use substring ? >> The only time it's better to use a regular expression than substring is >> when substring isn't applicable--that is, when what you're trying to match >> isn't a fixed string. You wouldn't bother with a regular expression just >> to find out if a string contains the substring "foo" somewhere inside it. > > If I just ask in general when should I use regular expression instead of > doing the same thing with classes Then I'm afraid I don't understand the question. Regular expressions are a way to express a character-based pattern. They're used to confirm that a string matches, or to locate strings that match, a pattern (assuming the pattern *can* be expressed as a regular expression--not all string patterns can). What do you mean by doing "the same thing" with classes?
From: Arne Vajhøj on 10 Mar 2010 19:39 On 10-03-2010 11:31, Tony Johansson wrote: > I just wonder when is it better to use regular(Regex) expression then to use > substring ? Your goal is readable code. So as the complexity of the parsing goes up then you change tool: IndexOf+Substring -> Regex -> generated Parser Arne
|
Next
|
Last
Pages: 1 2 Prev: XML Serialization with nullable values Next: Save setting to registry using C# |