首页 > 解决方案 > startwith 以 Apache free 标记结尾并包含在其中

问题描述

如何在 . string starts with_ ends with_ 是否有任何可用的预定义containsapache free markerfunction

HelloIamShruti
IamShrutiHello
ShrutiHelloSharma

如果我想检查starts with "Hello" first string should be returned 如果我想检查ends with "Hello" second string should be returned 如果我想检查contains "Hello" last string should be returned

标签: freemarkerdata-processing

解决方案


可用于您的请求的 Freemarker 方法是:

  • 开始于,例如。"redblue"?starts_with("red")将返回真。
  • 结束,例如。"redblue"?ends_with("red")将返回假。
  • 包含,例如。<#if "piceous"?contains("ice")>It contains "ice"</#if>将显示消息

当您希望单词被包含但不在开头或结尾时,只需添加一个 if 条件来检查 ifstarts_withends_withresult 为 false。


推荐阅读