Rob Bamforth's Blog
Java, SQL, MySQL, Networking, SQL Server, PHP, COM, DBA + ODBC

JAVA replace string within a string

The following code replaces an instance of a string within a string:

String testString = “This is a text string”
testString = testString.replace(“text string”, “sentance”);

testString will now print “This is a sentance”.

The replace() function is case sensative, and will only carry out the replace if the case matches both strings.

No Responses Yet to “JAVA replace string within a string”

Leave a Reply