Open In App

JSTL fn:containsIgnoreCase() Function

In the input string, if we need to check whether the input string has the specified string or not by ignoring its case then we can use the JSTL fn:containsIgnoreCase() Function. In this article, we will see the detailed Syntax of the fn:containsIgnoreCase() function along with its parameters, we will also see the practical implementation of this function in terms of examples.

JSTL fn:containsIgnoreCase() Function

This function returns the boolean value as true. If the input string has the specified string by ignoring the case otherwise, the false value is been returned.



Syntax of JSTL fn:containsIgnoreCase() Function

${fn:containsIgnoreCase(String str, String substring)}

Where,

Example of JSTL fn:containsIgnoreCase() Function

Below is the implementation of JSTL fn:containsIgnoreCase() Function:






<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    
<html>
  <head>
      <title>JSTL fn:containsIgnoreCase() Example</title>
  </head>
  <body>
    <c:set var="mainString" value="Welcome to GeeksforGeeks"/>
    <c:set var="substring1" value="geeks"/>
    <c:set var="substring2" value="Java"/>
    <p>Original String: ${mainString}</p>
      
    <p>Does "${mainString}" contain "${substring1}" (case-insensitive)? ${fn:containsIgnoreCase(mainString, substring1)}</p>
    <p>Does "${mainString}" contain "${substring2}" (case-insensitive)? ${fn:containsIgnoreCase(mainString, substring2)}</p>
      
  </body>
</html>

Output:

Explanation of the above Program:


Article Tags :