首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >fn:匹配给出无效的正则表达式错误。

fn:匹配给出无效的正则表达式错误。
EN

Stack Overflow用户
提问于 2018-12-13 11:19:58
回答 1查看 298关注 0票数 1

我有一个XML作为

代码语言:javascript
复制
<Root>
<Child><p><b>The Perfect Fit for Any Space</b></p> <p>Challenging the essence of how we define a desktop PC, GIGABYTE engineers have developed an ultra compact PC with a brushed aluminum surface chassis design. Ideal for a broad range of computing applications at home or in the office, the BRIX expounds sheer simplicity and convenience. With a broad choice of processors covering the entire performance spectrum, the BRIX sets a new standard for desktop miniaturization that makes it perfect as a discreet HTPC/multimedia hub, an ultra-low power PC for the family, an office PC or as a digital signage unit.</p> <p><b>Intel&reg; Celeron&reg; Processor</b><br /><br />GIGABYTE BRIX supports Intel third-generation low-power quad-core SoC processors which feature power-efficient 10W Intel&reg; Celeron models. From a simple internet access point to a high end multimedia station, the GIGABYTE BRIX a broad range of usage scenarios and the ultimate space flexibility. GIGABYTE BRIX is expected to deliver up to 23% improvement in productivity over previous generation.</p> <p><b>Supports DDR4 Memory</b></p> <p>GIGABYTE BRIX provides a 128-bit memory controller that supports DDR4 at up to 2400MHz. DDR4 is a type of synchronous dynamic random-access memory with a double data rate and high bandwidth interface. The primary advantages of DDR4 over its predecessor, DDR3, include higher module density and lower voltage requirements, coupled with higher data rate transfer speeds.</p> <p><b>Connecting the Future - USB Type-C&trade;: The World's Next Universal Connector</b></p> <p><b>Reversible USB Type-C&trade; with USB 3.0</b><br />The USB Type-C&trade; is a new reversible connector that is loaded with useful features such as USB 3.0 support for 5 Gb/s transfer speed. </p> <p><b>USB 3.0 and Network Connectivity</b><br />GIGABYTE BRIX&trade; also includes a M.2 module offering IEEE 802.11ac Wi-Fi and the latest Bluetooth 4.2, providing connectivity for low power Bluetooth users to easily connect mobile devices.</p> <p><b>SuperSpeed 4K HD Entertainment</b></p> <p><b>Supporting the Newest Standards in Multimedia <br /></b>GIGABYTE ensures users won't be limited by the standards or connections on the BRIX, by including HDMI 2.0 and support for HDCP 2.2 users can rest assured that their device will be able to display content to its full potential. The BRIX supports native resolutions of 4K at 60Hz, presenting unrivaled visual clarity and stunning realism to owners of UHD displays.</p> <p><b>Multi-display productivity with HDMI 2.0 &amp; DisplayPort</b><br />BRIX supports up to three independent displays through HDMI 2.0 and a DisplayPort without the need for an additional graphics card. Support for two display is only possible with daisy-chain connections through Display Port.</p> <p><b>Graphics that Captivate</b></p> <p>Intel&reg; HD Graphics deliver 10% more performance than its predecessor. With the new media engine users are able to, watch, create, edit, share and game all with captivating visuals. This media engine offers HEVC 10-bit hardware acceleration which improves upon the 4K viewing and content creation performance significantly versus previous generation processors. The BRIX now has the ability to drive premium content up to 4K UHD, so users can enjoy amazing and vibrant multimedia experiences on compatible displays.</p> <p><b>2.5" Hard Drive Support</b></p> <p>Utilizing SATA III 6 Gb/s high speed data transfer technology, the GIGABYTE BRIXs supports the installation of one 2.5" SATA 6Gbps HDD or Solid State Drive (SSD) and one M.2 2280 SSD module. This allows for optimized storage configurations which combine fast M.2 performance with larger capacity 2.5" hard drive. </p></Child>
</Root>

let $a := /Root/Child/string()

当我执行fn:matches($a, $a)时,它会给出XDMP-REGEX错误。我无法理解它是因为哪一个角色而失败的。错误片段

代码语言:javascript
复制
[1.0-ml] XDMP-REGEX: (err:FORX0002) fn:matches("<p><b>The Perfect Fit for Any Space</b></p> <p>Challenging the e...", "<p><b>The Perfect Fit for Any Space</b></p> <p>Challenging the e...") -- Invalid regular expression
EN

回答 1

Stack Overflow用户

发布于 2018-12-14 13:54:27

fn:matches()用于测试正则表达式是否匹配字符串。第二个参数需要是有效的regex模式。

如果$pattern的值根据5.6.1正则表达式语法中描述的规则无效,则引发动态错误。

该元素的计算字符串值不是有效的regex表达式。有些字符,如字符串中的/,需要转义。此外,尽管它是有效的,除非您在该字符串中转义(),否则它不会查找那些文字字符,它将尝试创建一个regex捕获组。

不是试图找出如何将随机字符串转换为有效的regex表达式,而是使用其他字符串比较选项.

如果试图确定该节点的原子化字符串值是否相等,则可以使用eq=运算符比较字符串值:

代码语言:javascript
复制
$a eq $a

如果要查看第二个参数是否包含在第一个参数值中,可以使用fn:contains(),它需要简单的字符串(没有regex模式)作为参数值:

代码语言:javascript
复制
fn:contains($a, $a)

如果您试图测试两个节点的相等性,而不仅仅是它们的计算字符串值,那么您可以使用fn:deep-equals()。但是当然,相同的变量是相等的,所以比较fn:deep-equals($a, $a)仍然没有意义。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53760702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档