本文介绍了验证爱尔兰手机号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以xxx-xxxxxxx格式验证爱尔兰手机号码。
前三位数应为083,086,087或089.接下来的七位数字应为整数。

I want to validate an Irish mobile phone number in the format xxx-xxxxxxx.The first three digits should be 083, 086, 087, or 089. The next seven digits should be integer numbers.

我尝试使用此HTML5验证模式:

I tried using this HTML5 validation pattern:

<input type="text" id="phone_no" name="owner[phone]" value="" pattern="([0]{1}[8]{1}[3|6|7|9]{1}[0-9]{7})">

代码无效。如何验证此信息?

The code is not working. How can I validate this information?

推荐答案

您放在方括号中的任何内容都会转换为任何这些字符。

Anything you put in square brackets translates to "any of these characters".

所以 1 [abcde] 2 1相同(a | b | c | d | e)2

此外,默认情况下,单个字母的大小为1。所以 [x] {1} x 相同。

Also, by default a single letter has size one. So [x]{1} is the same as x.

[0-9] 与数字相同,可以表示为 \d

And [0-9] is the same as a digit, which can be expressed as \d

试试这个正则表达式,它更容易理解:

Try this regex, it's easier to understad:

08[3679]-\d{7}

这篇关于验证爱尔兰手机号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 19:07