- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在努力寻找合适的解决方案:-
我需要一个匹配所有英国电话号码和手机的正则表达式。
到目前为止,这似乎涵盖了英国的大部分数字:
^0\d{2,4}[ -]{1}[\d]{3}[\d -]{1}[\d -]{1}[\d]{1,4}$
最佳答案
这个正则表达式可以吗?
// using System.Text.RegularExpressions;
/// <summary>
/// Regular expression built for C# on: Wed, Sep 8, 2010, 06:38:28
/// Using Expresso Version: 3.0.2766, http://www.ultrapico.com
///
/// A description of the regular expression:
///
/// [1]: A numbered capture group. [\+44], zero or one repetitions
/// \+44
/// Literal +
/// 44
/// [2]: A numbered capture group. [\s+], zero or one repetitions
/// Whitespace, one or more repetitions
/// [3]: A numbered capture group. [\(?]
/// Literal (, zero or one repetitions
/// [area_code]: A named capture group. [(\d{1,5}|\d{4}\s+?\d{1,2})]
/// [4]: A numbered capture group. [\d{1,5}|\d{4}\s+?\d{1,2}]
/// Select from 2 alternatives
/// Any digit, between 1 and 5 repetitions
/// \d{4}\s+?\d{1,2}
/// Any digit, exactly 4 repetitions
/// Whitespace, one or more repetitions, as few as possible
/// Any digit, between 1 and 2 repetitions
/// [5]: A numbered capture group. [\)?]
/// Literal ), zero or one repetitions
/// [6]: A numbered capture group. [\s+|-], zero or one repetitions
/// Select from 2 alternatives
/// Whitespace, one or more repetitions
/// -
/// [tel_no]: A named capture group. [(\d{1,4}(\s+|-)?\d{1,4}|(\d{6}))]
/// [7]: A numbered capture group. [\d{1,4}(\s+|-)?\d{1,4}|(\d{6})]
/// Select from 2 alternatives
/// \d{1,4}(\s+|-)?\d{1,4}
/// Any digit, between 1 and 4 repetitions
/// [8]: A numbered capture group. [\s+|-], zero or one repetitions
/// Select from 2 alternatives
/// Whitespace, one or more repetitions
/// -
/// Any digit, between 1 and 4 repetitions
/// [9]: A numbered capture group. [\d{6}]
/// Any digit, exactly 6 repetitions
///
///
/// </summary>
public Regex MyRegex = new Regex(
"(\\+44)?\r\n(\\s+)?\r\n(\\(?)\r\n(?<area_code>(\\d{1,5}|\\d{4}\\s+"+
"?\\d{1,2}))(\\)?)\r\n(\\s+|-)?\r\n(?<tel_no>\r\n(\\d{1,4}\r\n(\\s+|-"+
")?\\d{1,4}\r\n|(\\d{6})\r\n))",
RegexOptions.IgnoreCase
| RegexOptions.Singleline
| RegexOptions.ExplicitCapture
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
//// Replace the matched text in the InputText using the replacement pattern
// string result = MyRegex.Replace(InputText,MyRegexReplace);
//// Split the InputText wherever the regex matches
// string[] results = MyRegex.Split(InputText);
//// Capture the first Match, if any, in the InputText
// Match m = MyRegex.Match(InputText);
//// Capture all Matches in the InputText
// MatchCollection ms = MyRegex.Matches(InputText);
//// Test to see if there is a match in the InputText
// bool IsMatch = MyRegex.IsMatch(InputText);
//// Get the names of all the named and numbered capture groups
// string[] GroupNames = MyRegex.GetGroupNames();
//// Get the numbers of all the named and numbered capture groups
// int[] GroupNumbers = MyRegex.GetGroupNumbers();
area_code
和
tel_no
以将其分解并更容易提取。
关于RegEx:英国固定电话、手机号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3669516/
我有以下方法可以向邮政编码添加空格: function isValidPostcode(p) { var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-
我希望能够从随机字符串中获取邮政编码。 我可能收到的字符串 2 Castlebar Park, London, Greater London W5 1BX, UK The Ludgrove Club,
这个问题已经有答案了: Date api for managing off days in an year? (2 个回答) 已关闭 4 年前。 我需要防止在公共(public)假期期间进入 park
我在下面有这个测试代码。 行///1///和///2///是备选方案。 如果我使用行///2///输出看起来有问题,似乎它没有说明美国波士顿和英国伦敦全年相差 5 小时的事实。如果我使用行///1//
我一直在搜索Highmaps Map Collection并且找不到英国的 map 数据。有谁知道在哪里可以找到这个?他们有这么多不同国家的国家 map ,却没有英国的 map ,这似乎很奇怪。 最佳
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
我已经注册了一个 token 来访问国家铁路(英国)Live Departure Boards API,但我似乎无法使用它。谁能指出我做错了什么? 我使用 WSDL.EXE 构建了一个 C# SOAP
在 mac 终端应用程序中有一个设置(首选项 -> 键盘),可让您设置“使用选项作为元键”。这很有用,因为许多 unix 机器使用 bash作为默认 shell 并且具有 emacs 键绑定(bind
我正在尝试比较两个日期。其中一个是用户在创建新点时输入的,其中有一个日期字段,模型如下所示。 [Required] [DataType(DataType.Date)] [DisplayFormat(D
我原以为这是很多人需要的东西,但我似乎找不到任何用 Go 做过的人的包或 repos/playground 示例。 目标是转换一个字符串/ float ,使1.20(输入)变成1/5(输出),1.29
我正在开发一个需要连接到互联网的应用程序。到目前为止,我一直在使用 Wifi 和 WAP 2 连接 UID 进行 Http 连接,并且一切正常。但是现在客户端告诉他希望使用直接 TCP 连接,因为使用
我在博客中发布了 FT map 。为此,我使用了以下代码: http://fusion-tables-api-samples.googlecode.com/svn/trunk/FusionTables
我正在使用 phonegap build 来制作应用程序。我已经集成了一个 Paypal SDK 插件,但它只接受来自美国或英国用户的信用卡: https://developer.paypal.com
有了新的Google Play优化建议,它给我的建议之一是: Your app is popular with users who speak English (United Kingdom) but
我想在 iPhone 应用程序中使用 TradeDoubler(欧洲)和 LinkShare(美国、加拿大)并链接到应用程序商店。我已经知道我总是会被带到正确的商店。但是每个国家/项目的附属链接都是不
我希望将 paypal 集成为我的客户的支付网关。 我给客户提供一个在线软件,向用户销售产品,所以我作为第三方开发paypal,所以钱是直接转入我客户的paypal账户,而不是我的。 我已经在 pay
我有这张图片。这是一张英国 map (不包括南爱尔兰): 我已成功获取纬度和经度并将其绘制到这张 map 上,方法是获取英国最左边的经度和最右边的经度,并使用它们计算出将点放在 map 上的位置。 这
我已经尝试了多个代码,例如这样 Sub DateFixer() Application.ScreenUpdating = False Application.Calculation =
用国语, countrycode | language US | English BR | Portuguese UK | English 在国名中, countrycode | name
嘿,我想知道如何使用 PHP 和 Google Maps Api 计算出 2 个邮政编码之间的距离。 任何人都有任何想法或示例链接。 最佳答案 假设您正在寻找 geographic distance
我是一名优秀的程序员,十分优秀!