I want to give a fragment of a string that will be considered as a literal string inside a larger regular expression, and this expression should match the POSIX Extended Regular Expressions .
This question is very similar to this existing question , except that the answer there does not satisfy me, as it suggests using Pattern.quote()one that relies on a special one \Qand \Ethose that are supported by Java regular expressions but do not conform to the POSIX Extended format.
For example, I want to one.twobecome one\.two, not \Qone.two\E.
source
share