1
When I put b in pattern.compiler
he returns the matcher.find
as false, because he can’t even find a pattern precisely because of the b.
Following the code I use:
final Pattern py = Pattern.compile("\\b(print|True|False|int|str|float|bool)\\b)");
edittext.addTextChangedListener(new TextWatcher() {
Matcher m;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable e) {
m = py.matcher(e);
while (m.find()) {
e.setSpan(new ForegroundColorSpan(Color.WHITE),m.start() ,m.end() ,0);
}
}
});
But if I take out the b works but not the way I want.
What are you testing for? Pattern doesn’t give us a hint of the real problem
– Guilherme Lautert
I don’t have a PC and I compile java in app by Sketchware. It is an IDE
– AndronCreation