我知道在使用saxon的XSLT中不允许使用前瞻模式,但我需要知道如何在XSLT 2.0中使用这个正则表达式:
<xsl:if test='matches($value,"^(?!\s*$).{x,y}$")'>
其中x和y是数字。有什么建议吗?
答案 0 :(得分:2)
根据https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html,Java语言支持例如(?!X)
为X, via zero-width negative lookahead
,因此您应该能够使用标记;j'
启用Saxon,就像在matches(string, '(?!subpattern1)subpattern2', ';j')
中一样,Saxon允许您(http://saxonica.com/html/documentation/functions/fn/matches.html)切换使用该标志的Java正则表达式语言。