Open In App

JSTL fn:substringAfter() Function

In the main string, if we want to return the subset of the string followed by a specific substring then we can use the JSTL fn:substringAfter() Function.

JSTL substringAfter() Function

This function mainly returns the portion of the string that comes after the given string value.



In this article, we will see the detailed Syntax of the fn:substringAfter() function along with its parameters, we will also see the practical implementation of this function in terms of examples.

Syntax of substringAfter() Function

${fn:substringAfter(String str, String delimiter)}


Where,



Example of JSTL fn:substringAfter() Function

Below is the implementation of JSTL fn:substringAfter() 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 substringAfter Example</title>
  </head>
  <body>
    <c:set var="string1" value="Welcome to GeeksforGeeks."/>
      
    <c:set var="substringResult" value="${fn:substringAfter(string1, 'Geeks')}" />
      
    <p>Original String: ${string1}</p>
    <p>Substring after "Geeks": ${substringResult}</p>
  </body>
</html>

Output:

Explanation of the above Program:

Article Tags :