I need a regular expression that only validates UK mobile numbers.
A UK mobile number can be between 10-14
digits and either starts with 07
, or omits the 0
and starts with 447
.
Importantly, if the user adds +44
it should be rejected.
So these would be valid:
07111111111
447111111111
and these would be invalid:
+4471111111111
021929182711
00701029182
What I have so far:
rule = re.compile(r'^\+?(44)?(0|7)\d{9,13}$')if not rule.search(value):msg = u"Invalid mobile number."raise ValidationError(msg)
This does not validate according to my rules yet; could someone help?