Java jstl function containsignorecase
The JSTL (JavaServer Pages Standard Tag Library) fn
tag library provides a set of functions for manipulating strings, collections, and other objects in JSP (JavaServer Pages) pages. One of the functions in the fn
tag library is the fn:containsIgnoreCase
function, which is used to check if a string contains a substring, ignoring case.
The fn:containsIgnoreCase
function takes two arguments: a string and a substring to search for. The function returns a boolean value indicating whether the string contains the substring, ignoring case. The syntax of the function is as follows:
${fn:containsIgnoreCase(string, substring)}So:ecruwww.theitroad.com
where string
is the string to search in, and substring
is the substring to search for.
For example, to check if a string contains the substring "example", ignoring case, you would use the following expression:
${fn:containsIgnoreCase('This is an Example String', 'example')}
This expression returns true
, because the string "This is an Example String" contains the substring "example", even though the case does not match.
You can also use variables instead of literals for the string
and substring
arguments. For example, if you have a variable text
containing a string, you can check if it contains the substring "example", ignoring case, using the following expression:
${fn:containsIgnoreCase(text, 'example')}
This expression returns true
if the variable text
contains the substring "example", even if the case does not match.
Note that the fn
tag library must be imported at the beginning of the JSP page using the following tag:
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
This imports the fn
tag library and assigns it a prefix of fn
.