django移动号码正则表达式

django移动号码正则表达式,django,mobile,Django,Mobile,我已经看到了许多手机示例以及手机号码字段的第三方软件包。但我想要的是: +国家/地区代码或空间(这3个是可选的)电话号码(最小范围号码=8,最大范围为13) 例:+6598654578 基于其中一个例子,它可以工作,但不是我想要的。 : 我做的是这样的: mobile_regex = RegexValidator(regex=r'^\+?1?\d{1-3}?\,?\s?\d{8-15}$', message="Phone number must not consist of space and

我已经看到了许多手机示例以及手机号码字段的第三方软件包。但我想要的是:

+国家/地区代码或空间(这3个是可选的)电话号码(最小范围号码=8,最大范围为13) 例:+6598654578

基于其中一个例子,它可以工作,但不是我想要的。 :

我做的是这样的:

mobile_regex = RegexValidator(regex=r'^\+?1?\d{1-3}?\,?\s?\d{8-15}$', message="Phone number must not consist of space and requires country code. eg : +6591258565")

但它不起作用。我做错什么了吗?请帮助我

如果您使用破折号而不是逗号,并且根据您的指示,您还希望同时捕获+和国家代码,此正则表达式适用于我:


^(\+\d{1,3}),?\s?\d{8,13}
您使用破折号而不是逗号,并且根据您的指示,您还希望同时捕获+和国家代码,此正则表达式适用于我:

^(\+\d{1,3})和?\s?\d{8,13}

可能重复的
mobile_regex = RegexValidator(regex=r'^\+?1?\d{1-3}?\,?\s?\d{8-15}$', message="Phone number must not consist of space and requires country code. eg : +6591258565")