【问题标题】:How to find if the end of a string contains particular character如何查找字符串的末尾是否包含特定字符
【发布时间】:2022-01-02 16:58:21
【问题描述】:

示例 A = 将“{Test}”设置为当前时间

我想检查变量 A 在字符串末尾是否有 "。 我正在考虑使用 contains(),但后来我不知道如何在字符串末尾准确查找字符 ",而不管字符串的长度如何。 非常感谢您!

【问题讨论】:

  • XSLT 使用 XPath 作为其表达式语言,XSLT 1.0 XPath 1.0,因此请查看 XPath 1.0 字符串函数(即 substringstring-length)。

标签: xslt xslt-1.0


【解决方案1】:

在 XPath 1.0 中执行此操作的唯一方法是笨拙的测试 substring($x, string-length($x)) = $quotation-mark

XPath 2.0 引入了ends-with() 和正则表达式——是时候向前迈进了!

【讨论】:

    猜你喜欢
    • 2014-11-22
    • 2012-09-30
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    相关资源
    最近更新 更多