I want to replace the exact word using replace but I can't seem to figure out.
$value1 = "I brought tea for my team"
$newValue = "coffee"
$token = "tea"
$value1 -replace $token, $newValue
Actual Result:
I brought coffee for my coffeem
Expected result:
I brought coffee for my team
Fix:
$value1 = "I brought tea for my team"
$newValue = "coffee"
$token = "tea"
$value1 -replace "\b$token\b", $newValue
I brought tea
,tea was what I brought
,I brought "tea" for my team
)-replace "\b$token\b", $newvalue