I would like to have EditText with some simple validation. I would like it to gain decimal numbers in format 8 symbols before comma and 2 symbols after comma.
I've found some examples here, but I can't figure out why are they not working for me. I was trying to set InputFilter, but I can't create a valid regex.
public class DecimalDigitsInputFilter implements InputFilter {
Pattern mPattern;
public DecimalDigitsInputFilter(final int digitsBeforeZero,
final int digitsAfterZero) {
mPattern = Pattern.compile("place for my regex");
}
@Override
public CharSequence filter(final CharSequence source, final int start,
final int end, final Spanned dest, final int dstart,
final int dend) {
Matcher matcher = mPattern.matcher(dest);
if (!matcher.matches()) {
return "";
}
return null;
}
}