Skip to main content
added 68 characters in body
Source Link
oguz ismail
  • 51.8k
  • 16
  • 64
  • 83

Try using sed if that is possible:

echo $input"$input" | sed 's/\bst\b/street/g'

\b in GNU sed refers to word boundaries.

Also refer: https://unix.stackexchange.com/questions/184815/how-can-i-find-and-replace-only-if-a-match-forms-a-whole-wordHow can I find and replace only if a match forms a whole word?

Try using sed if that is possible:

echo $input | sed 's/\bst\b/street/g'

\b in GNU sed refers to word boundaries.

Also refer: https://unix.stackexchange.com/questions/184815/how-can-i-find-and-replace-only-if-a-match-forms-a-whole-word

Try using sed if that is possible:

echo "$input" | sed 's/\bst\b/street/g'

\b in GNU sed refers to word boundaries.

Also refer: How can I find and replace only if a match forms a whole word?

Source Link
Fazlin
  • 2.3k
  • 19
  • 31

Try using sed if that is possible:

echo $input | sed 's/\bst\b/street/g'

\b in GNU sed refers to word boundaries.

Also refer: https://unix.stackexchange.com/questions/184815/how-can-i-find-and-replace-only-if-a-match-forms-a-whole-word