Exact String Replace In Java

Exact String Replace Using Java Example explains how to replace exact string using java regular expression.

When you are in a situation where you just need to replace the exact string "Replace" from "Exact String Replace In Java"

For achieve this, we need to just put '\b' ("word boundary" in java regular expression) in between the words, that we are going to replace.

By using this regular expression allows you to perform a "whole words only" search using a regular expression and replace the specified string inside word boundary.

See the below regular expression example, which is showing how to replace an exact string in java.