As the title says, just looking for a string to match a client finishing sending data over a socket, so I might be looking for something like {"Message" : "END"}
in a JSON string for example.
A the most the strings will be a few hundred chars long.
So "emulating" a Contains() by using an IndexOf with OrdinalIgnoreCase is 400% faster than the builtin Contains().
String. contains works with String, period. It doesn't work with regex. It will check whether the exact String specified appear in the current String or not.
Java - String matches() Method This method tells whether or not this string matches the given regular expression. An invocation of this method of the form str. matches(regex) yields exactly the same result as the expression Pattern. matches(regex, str).
Yes, contains is case sensitive. You can use java. util.
They're both fast enough to be over before you know it. Better to go for the one that you can read more easily.
But from forums, blogs contains
is faster, but still negligible performance difference
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