So i have the string: "$STEP1 AB CF $STEP10" .I want to search and replace "$STEP1" with "XX", however when I use the "search and replace VI" ,the resulting string is "XX AB CF XX0" because the VI replaces the "$STEP1" in $STEP10 therefore giving me XX0 but my resulting string should be XX AB CF $STEP10.How do i search and replace only a whole word/string?Thank you
Solved! Go to Solution.
If you know that STEP1 will always be before STEP10, and will only appear once just make sure the "replace all" is false on the search and replace function. If not you may have to do something like search for the string AND check the length before you replace.
Edit: Or if $STEP1 always has a space after it you can search for "$STEP1 " and replace with "XX "
Right-click search-and-replace and select the "Regular expression" option. Then, instead of searching for "$STEP1", change your search string to "\$STEP1\b".
The leading "\" is to tell it to interpret the dollar sign literally instead of as a control character. The trailing "\b" tell it that it needs to find a boundary at the end of the search string. You might want to look up how regular expressions work to know more about what qualifies as a boundary.
The easy answer is; make sure you replace "STEP1 ", with a space, with "XX ", also with a space. That way STEP10 won't be caught be the filter.