I have searched the web for my query, but didn\'t get the answer which fits my requirement exactly. I have my string like below:
You can use Pattern.quote():
String regex = "(?
Using your example:
String delim = "|";
String regex = "(?
A B C The Steading\|Keir Allan\|Braco E
You can extend this to use a custom escape sequence as well:
String delim = "|";
String esc = "+";
String regex = "(?
A B C The Steading+|Keir Allan+|Braco E