【问题标题】:Regex in freemarkerfreemarker中的正则表达式
【发布时间】:2014-02-11 23:13:29
【问题描述】:

我是 freemarker 的新手。 例如:一个名为 content = "http://www.xyz.com/sites/" 的变量。那么如何签入ftl

        <#if content has "/sites/" in it>
                  do something
        </#if>

【问题讨论】:

    标签: regex freemarker


    【解决方案1】:

    您可以使用正则表达式和内置的matches freemarker。

    <#if content?matches(".*/sites/.*")>
       do something
    </#if>
    

    【讨论】:

    • 或者,content?contains('/sites/') 更简单。
    • matches 不会工作,对吧?那是一模一样的吗?您必须查看返回的子匹配的长度。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-12
    • 2015-12-29
    • 1970-01-01
    • 1970-01-01
    • 2015-12-13
    相关资源
    最近更新 更多