I need a regular expression to validate the mobile number up to 9 digits, if the telephone number starts with 8 otherwise 10 digits needs to be entered. The numbers must start either with 9 or 8 with above criteria.
+2
A:
Not sure about the answer, but you should check out this very useful website for reg expressions incase you are interested:
VoodooChild
2010-06-01 05:37:33
http://www.regular-expressions.info/ is also an invaluable resource.
Johnsyweb
2010-06-01 05:53:48
your expression is also accepting numbers statring with 1 ,2,3 ..so on. I need numbers starting with 8 or 9 with the above condition
skamale
2010-06-01 06:47:22
@skamale You didn't say anything special about numbers starting with 9. This regex matches only nine digit strings starting with 8 and ten digit strings starting with numbers other than 0 and 8. If that's not what you want, edit the question's wording to clarify it. Add a couple of examples of what should and should not be accepted.
Amarghosh
2010-06-01 07:01:39
A:
Use the following regular expression to match the phone numbers starting with 8 or 9.
^8|9(8\d{8}|[1-79]\d{9})$
rekha_sri
2010-06-01 08:40:56