Contain in Apache free marker

寵の児 提交于 2020-06-08 12:37:08

问题


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"
      } ]
};

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?

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


回答1:


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).

Demo



来源:https://stackoverflow.com/questions/62032594/contain-in-apache-free-marker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!