包含在Apache免费标记中 [英] Contain in Apache free marker

查看:75
本文介绍了包含在Apache免费标记中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面的对象由特定函数返回

I have below object returned by a particular function

    {"count":3,
      "items":[
       {
        "organizationCode": "FP1",
        "organizationName": "FTE Process Org"
      },
      {
        "organizationCode": "T11",
        "organizationName": "FTE Discrete Org"
      },
      {
        "organizationCode": "M1",
        "organizationName": "Seattle Manufacturing"
      } ]
};

用户必须搜索此对象中是否存在特定的字符串. 如果用户需要搜索T11,则可以输入T11'T11'"T11".所有这种情况都应该被接受.如果用户输入T1,则不应接受它(我要说是因为T11包含T1).如果用户输入"Seattle Manufacturing",则应接受 我正在尝试使用contain方法,但无法正常工作.我该怎么办?

user has to search whether particular string exist in this object or not. If user need to search T11 then he can enter either T11 or 'T11' or "T11" . all this case should be accepted. If user enteres T1 then it should not be accepted(I am mentioning because T11 contains T1). if user enters "Seattle Manufacturing" it should be accepted I am trying to use contain method but its not working. How can I do that?

我正在努力,因为关于freemarker的资料很少

I am struggling because there is very little material available regarding freemarker

推荐答案

因此第一步将是接受用户输入.然后,如果他们在查询中包含'",则从搜索中删除这些字符.此模式不是必需的.完成此操作后,您可以使用此模式查找匹配项(?<=organization(?:Name|Code)":)\s+(?i)"T11".您将要用其剥离的查询内容替换模式的T11部分.这将不区分大小写.如果您需要使模式区分大小写,则可以删除(?i).

So the first step would be to accept the user input. Then if they include ' or " in their query, strip those characters off of their search. It's not necessary for this pattern. Once you've done that, you can use this pattern to find matches (?<=organization(?:Name|Code)":)\s+(?i)"T11". You'll want to replace the T11 portion of the pattern with whatever their stripped query is. This will not be case sensitive. If you need the pattern to be case sensitive you can remove the (?i).

演示

这篇关于包含在Apache免费标记中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆