From: Tony Johansson on
Hi!

I just wonder when is it better to use regular(Regex) expression then to use
substring ?

//Tony


From: Harlan Messinger on
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
"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
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
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