在xml架构(xsd)上嵌入正则表达式(phone numb validate)时出错

时间:2022-12-30 17:19:13

I don't understand why this regular expression for validation international phone number gives an error when embedded on xml-schema:

我不明白为什么这个用于验证国际电话号码的正则表达式在嵌入xml-schema时会出错:

<xs:simpleType name="phoneType">
  <xs:restriction base="xs:string">
      <xs:pattern value="^\+(?:[0-9] ?){6,14}[0-9]$" />
  </xs:restriction>
</xs:simpleType>

What's wrong with it? Does support group matching? Why is not supported by Xml Schema ?

它出什么问题了?支持组匹配吗?为什么不支持Xml Schema?

Thank you very much.

非常感谢你。

Indrit

2 个解决方案

#1


XML schema supports group matching, but not capturing or lookaround. This means that it doesn't the ?: non-capturing group.

XML模式支持组匹配,但不支持捕获或环视。这意味着它不是?:非捕获组。

According to http://www.regular-expressions.info/xml.html it also doesn't support the ^ and $ anchors.

根据http://www.regular-expressions.info/xml.html,它也不支持^和$ anchors。

#2


It's probably the anchors (^ and $). In XML Schema, all regexes are implicitly anchored at both ends. Explicit anchors are not supported.

它可能是锚点(^和$)。在XML Schema中,所有正则表达式都隐式锚定在两端。不支持显式锚点。

#1


XML schema supports group matching, but not capturing or lookaround. This means that it doesn't the ?: non-capturing group.

XML模式支持组匹配,但不支持捕获或环视。这意味着它不是?:非捕获组。

According to http://www.regular-expressions.info/xml.html it also doesn't support the ^ and $ anchors.

根据http://www.regular-expressions.info/xml.html,它也不支持^和$ anchors。

#2


It's probably the anchors (^ and $). In XML Schema, all regexes are implicitly anchored at both ends. Explicit anchors are not supported.

它可能是锚点(^和$)。在XML Schema中,所有正则表达式都隐式锚定在两端。不支持显式锚点。