`s"\\Q$CARET\\E".r.findAllIn(str).size` should be equivalent ;)