posted 22 years ago
It takes time to parse a new pattern so the JVM can understand what it's supposed to be looking for. The String methods you cite each compile a new Pattern internally using the regex String argument whenever they are invoked. If you're going to use the same regex String more than once, it's more efficient to just compile it into a Pattern once, and use the Pattern and Matcher methods as many times as necessary. But if performance isn't a concern, or you're only going to use the regex once, then the String methods are a bit easier to use.
"I'm not back." - Bill Harding, Twister