From: Tony Johansson on 11 Mar 2010 02:35 "Harlan Messinger" <hmessinger.removethis(a)comcast.net> skrev i meddelandet news:7vqj5aFv80U1(a)mid.individual.net... > 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? In .NET we have a framework that consist of a lot of classes. these classes can be used when we want to change the state of an object. So in almost every case whan you will use a regex you can almost always do the same this by using the classes that exist in the framework but the code will be greater then using regex. Hope you understand what I mean. //Tony
First
|
Prev
|
Pages: 1 2 Prev: XML Serialization with nullable values Next: Save setting to registry using C# |