But calling toUpperCase() on a large String (several thousands characters) may have a negative impact on memory usage. This is one of those cases where you must make a trade off between better speed (toUpperCase(), contains()) and less memory (
Pattern). If this operation is needed many times reusing a Pattern object may even be better.