I trying to find out if one string contains another. But, unfortunately, fn:contains
function is case-sensitive. Are there are any ways to make it case-insensitive?
I tried to put both into one case:
fn:contains(car.color.toLowerCase(), smartBean.txt.toLowerCase()) ? 'true' : 'false'
But it didn't work due to method's brackets. I also can't use f:to-upper
inside f:contains
function.
There's a fn:containsIgnoreCase()
. Just use it instead.
#{fn:containsIgnoreCase(car.color, smartBean.txt)}
By the way, your failed toLowerCase()
attempt should have been done as follows:
#{fn:contains(fn:toLowerCase(car.color), fn:toLowerCase(smartBean.txt))}
Using toUpperCase()
works as good as well:
#{fn:contains(fn:toUpperCase(car.color), fn:toUpperCase(smartBean.txt))}
Perhaps you just made an EL syntax error.
Note that the ? 'true' : 'false'
part is completely superfluous as that's already returned by the function.