Short answer: for your example, yes.
Long answer: Yes, but Pattern.quote is more flexible. What if you want some of your templates to be quoted? How:
Pattern.compile(Pattern.quote(s) + "+", x)
When the Pattern.LITERAL flag is set, even the + symbol will now be processed literally.
If you don't trust the documentation, maybe check out the source code on Google Code Search for Pattern.compile .
From which I can get the source code:
If the LITERAL flag is not set, regardless of all other flags, it will look for any quotes \ Q ... \ E and manually launch special characters, just as you would expect.
If the LITERAL flag is set, it will convert the entire template using the newSlice method, and there are special cases for the smallest CASE_INSENSITIVE flag and the UNICODE_CASE flag
Zach l
source share