How to replace a substring in a string (case sensitive) in ColdFusion

Replace() - replace a substring in a string (case sensitive)

Replace.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Replace function example: how to replace a substring in a string (case sensitive)</title>
</head>

<body>
<h2 style="color:HotPink">Replace Function Example [case sensitive]</h2>

<cfset TestString="This is test string. this is  test. Only Test">
<cfoutput>
<b>
TestString: #TestString#
<br />
TestString[after replace substring "test" with "simple" first ]: #Replace(TestString,"test","simple","one")#
<br />
TestString[after replace substring "test" with "simple" all ]: #Replace(TestString,"test","simple","all")#

</b>
</cfoutput>

</body>
</html>





More ColdFusion examples