I have a simple regex :
String expr = "#^" + STARTER + "[.]" + ENDER + "$#";
c = c.replaceAll(expr, STARTER + REPLACEMENT + ENDER);
Result :
A string which contains
STARTER an exemple ENDER
matches but :
STARTER an (exemple) ENDER
doesn’t match.
Why are the characters ), ( and $ excluded from the . regex class?
How can I make it accept any character?
Assuming that
STARTERandENDERare supposed to be literal strings, not regexes themselves, and that your goal is to match a string that starts withSTARTER, ends withENDERand may contain anything (except newlines) in-between, you could useThis means that there can be only one match per string.
So, if
STARTER == "Start",ENDER == "End"andREPLACEMENT == "Replace", thereplaceAll()call would do the following:Since this doesn’t make much sense, you might want to explain what your actual goal for this regex is.