#733 Another Convenience that would be... convenient

yachris Sat 29 Aug 2009

Hello,

It would be nice if Regex had a find which would be a convenience for RegexMatcher.find, just like it has matches for RegexMatcher.matches. It's nice to be able to match just part of a string, rather than figure out how to match the whole string.

Thanks!

brian Sat 29 Aug 2009

The problem is that Regex is const and immutable, but find is a stateful operation that requires accessing further information from the RegexMatcher which is mutable. That is why there are two classes.

The const type system becomes very important once you start to do concurrency. For example you can pass a Regex b/w threads or store in a static field, but you cannot pass a RegexMatcher.

yachris Sat 29 Aug 2009

Good distinction, thanks.

Login or Signup to reply.