Hi. How are the classes in this package different from what I can do with the String class *specifically with the match,replace and split* methods. Why would I want to use Pattern or Match over String?. Thanks!
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
Space pants. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth