问题
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