正则表达式移动和固定电话号码 [英] regular expression mobile and landline number

查看:213
本文介绍了正则表达式移动和固定电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以这种格式(021)123-4567或(027)123-4567或此格式(04)970-0676的固定电话号码获得手机号码。我有一个正则表达式,除了它不包含' - ',前三个或两个数字包含在大括号(027)或(04)字符中。

我想要什么也就是在括号之后在第三个数字之后具有例如(04)970-<或(027)635-<

i want to have a mobile phone number in this format (021)123-4567 or (027)123-4567 or landline number in this format (04)970-0676. i have a regular expression which does that except it doesn't contain the '-' and the first 3 or 2 digits are wrapped in the curly brackets (027) or (04) character.
what I want also is after the brackets is to have a hypen after the third digit e.g (04)970- < or (027)635- <

这就是我所拥有的。

(^\([0][2]\d{1}\))(\d{6,8}$) 

或者这个显示电话号码中可能的代码和可能的字符数这一个在这里是我想要的除了缺少的信息。

or this one which shows the possible codes and possible number of characters in phone number this one here is what i kinda want except for the hypen is missing.

'/^(\((03|04|06|07|09)\)\d{7})|(\((021|022|025|027|028|029)\)\d{6,8})|((0508|0800|0900)\d{5,8})$/'


推荐答案

尝试:

/^\(0\d{1,2}\)\d{3}-\d{4}$/

正则表达式值得学习 http://www.regular-expressions.info/

这篇关于正则表达式移动和固定电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆