Possible Duplicate:
Regex.IsMatch vs string.Contains
Which is faster, preferable and why?
What the difference in mechanisms between two?
I need to search for some values from UserAgent, most of values can be used without wildcards (e.g. if I want to catch cellular phones I search for iPhone
instead of *iPhone*
wildcards).
What is faster
Try measuring. But this is the wrong question, see below.
preferable
If I want to match a fixed string String.Contains
does just what I need. If I need to pattern match, then String.Contains
is useless.
Comparing the performance of these is irrelevant, they do completely different things. Use the right tool first, and only then if your performance is a problem use profiling to identify hot parts of your code to look at.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With