JSTL fn:substringAfter() Function
Last Updated :
08 Dec, 2023
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,
- ${fn:substringAfter( . . . )}: This is the JSTL function used to return the subset of the string followed by a specific substring.
- str: This is the main string or input string from which the subset of the string will be extracted.
- delimiter: The delimiter or marker after which the subset of the string will be returned.
Example of JSTL fn:substringAfter() Function
Below is the implementation of JSTL fn:substringAfter() Function:
HTML
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
< 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:
- In the above example, firstly we have initialised values to the string1 and substringResult variable as “Welcome to GeeksforGeeks” and the function output.
- We are using the fn:substringAfter() Function in which we have passed the parameter of string1 and the delimiter as “Geeks“.
- So we have got the result as forGeeks which is substring after Geeks delimiter.
- We have printed the result in HTML by using the <p> tag.
Share your thoughts in the comments
Please Login to comment...