Unless you need resiliency in the pattern, you are better of using IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as well
as you demonstrate below.
Unless you need resiliency in the pattern, you are better of using IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as well
as you demonstrate below.
IndexOf is going to be massively faster in most cases in searching for
start and end tags of fixed form like you show below. Actually I take
that back, you are actually going to need to use something that does
a substring match:
Unless you need resiliency in the pattern, you are better of using IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as well
as you demonstrate below.
IndexOf should be, given that Regexes have the tradeoff of more advanced functionality. Try profiling it - I tried compuware devpartner community edition profiler - free, integrates into VS.NET and I must say the support is quite good aswell. Not to mention works dead well and highlights the slowest line of code in red - something I find dead useful!
Bill Yin said:
Which faster using indexOf or RegularExpressions?
Justin Rogers said:
Unless you need resiliency in the pattern, you are better of using IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as well
as you demonstrate below.
Regex performance depends on the complexity of the search pattern. If you
search for a fixed pattern, to compare it's speed with IndexOf, Regex'es are
faster (than IndexOf) on long strings. (personal experience)
Niki
Bill Yin said:
Which faster using indexOf or RegularExpressions?
Justin Rogers said:
Unless you need resiliency in the pattern, you are better of using IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as well
as you demonstrate below.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.