12-05-2018 12:53 PM
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.
12-05-2018 01:14 PM - edited 12-05-2018 01:34 PM
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 "
12-05-2018 01:45 PM - edited 12-05-2018 01:46 PM
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.
12-06-2018 02:47 AM
this works for me..i was using the "\b" but the problem was that i wasn't escaping the dollar sign
12-06-2018 08:51 AM
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.
/Y