Here I want validation for the mobile number start with +91 and after 10 digit number.
I am add the +91 pincode into edittext like:
edtmobile.append("+91(-)"); so when display the edittext(UI) there is already +91and after edit 10 digit number
I am using Reg Ex like :
String regExPhone = "(+91(-)?|91(-)?|0(-)?)?[0-9]{10}";
but got the error like :
E/AndroidRuntime( 1411): java.util.regex.PatternSyntaxException: Syntax error U_REGEX_RULE_SYNTAX near index 2:
E/AndroidRuntime( 1411): (+91(-)?|91(-)?|0(-)?)?[0-9]{10}
E/AndroidRuntime( 1411): ^
Please let me know where I do mistake, and there is another solutions for same.
Thanks.
+is a special character in regex and needs escapingtry
you also do not need to group single characters to make them optional, so
would be the same.