I want to restrict input to match the statement change = where word and value are both arbitrary words (sequences of characters that don't include spaces) and only one space exists (between the word "change" and a) in the input.
For example, "change variable=value" is valid but "change variable= value" and "change this" are not.
My attempt:
private static final Pattern SET = Pattern.compile("change\\s\\w=\\w");
I use the clause
if(SET.matcher(command).find())
{
...
}
to check for proper output but haven't been able to get the function to work properly. Where am I going wrong? What syntax should I use for this particular regular expression? (Please let me know if further clarification is needed)