I'm new to regex and trying to get this statement to pass. What I'm trying to do is check the first character or two from the string.
I want to see that if it starts with a number then the statement will be true. I also want to check that if the first character is a "(" then i want to check that the next number is a digit too.
So far I've got:
if (str.matches("^[(?\d")){
return true;
but this doesn't seem to work. ^ for anchoring to start, (? to check for optional parenthesis and then check if it's a digit afterwards. How have i stuffed up?
So 0800, (0800, (09, 09, should pass where as *08, (*0, AB, (AB, *AB should fail.
Thanks
Aucun commentaire:
Enregistrer un commentaire