JSTL fn:replace() Function

In this tutorial you will learn about the JSTL replace function.
JSTL Replace function is used to replace the string with another string.
This function replaces a string with the other string. It replaces all occurrences of a string.

Syntax:
The fn:replace () function has following syntax:
boolean replace(java.lang.String, java.lang.String, java.lang.String)
JSTL Replace Function Example-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL Replace Function Example</title>
</head>
<body>
  <c:out value="${fn:replace('Hello Dinesh','Dinesh','Rajput')}"></c:out>
</body>
</html>
Output: Hello Rajput

As you can see above, JSTL Replace function takes 3 parameters.

First parameter in JSTL replace function is the string which needs to be modified.

Second parameter in JSTL replace function is the target substring which needs to be replaced by .

Third parameter in JSTL replace function is the string which needs to be inserted inplace of second parameter.



<<Previous <<   || Index ||   >>Next >>






No comments:

Post a Comment