Find and replace for "whole words"

Hi there.

Seems like I may be missing something in the F&R function.

If I replace “0” with “0-3 months” and “10” with “10-18 months” I end up double changing the “10” as it matches both.

Ended up doing a regex to replace “0” with “zero” and “10” with ten but am thinking I may be missing an easier way ? Can I do a whole word search ?

Hi @NigelG,

That would be due to the functionality of our step Find and replace, where the “find the value” entered will be picked up each time it occurs in a cell. For example, if in this step you entered find “0” to be replaced with “0-3 months”, then if a row contained “20” it would be replaced with “20-3 months”.

If you have the step Use regex in your flow, I’d suggest using it to accomplish this instead so you can remove any latter redundant Find and replace steps. With this Use regex step, you can enter the expression value ^0$ or \b(0)\b to capture the single integer 0 value and the replace value of “0-3 months”. Through this step, even if 0 appears in a row with a cell value of 20, the Use regex step won’t replace it with “20-3 months” as the Find and replace step would due to their differing step functionality.

Let me know how that works out for you or if you’d like further clarification on the above.

1 Like

Thanks, just wanted to check I wasn’t missing a “Match Whole Word” checkbox somewhere :slight_smile:

1 Like