I have searched a lot for a regular expression or pattern that would work for me, but I haven't found any.
In a Edit text I want to allow first 4 digit and then 2 uppercase letters, so Ihave created a pattern:
private final Pattern sPattern = Pattern.compile("^[0-9]{0,4}[A-Z]{0,2}");
But it allows first 2 capital letters, too.
If i change my pattern to
private final Pattern sPattern = Pattern.compile("^[0-9]{0,4}[A-Z]{4,6}");
I am not able to get anything rright.
Please help me with this.
Thanks.
{4,6}means?{4,6}is a limiting quantifier that matches the preceding subpattern 4, 5 or 6 times. It has nothing to do with positions in string.