How to find a word within text using XSLT 2.0 and REGEX (which doesn't have \\b word boundary)?

℡╲_俬逩灬. 提交于 2019-12-01 13:12:05

You can use alternation to avoid repetition:

<xsl:if test="matches($prose, concat('(^|\W)', $word, '($|\W)'),'i')">

If your XSLT 2.0 processor is Saxon 9 then you can use Java regular expression syntax (including \b) with the functions matches, tokenize and replace by starting the flag attribute with an exclamation mark:

<xsl:value-of select="matches('all foo is bar', '\bfoo\b', '!i')"/>

Michael Kay mentioned that option recently on the XSL mailing list.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!