I need to find and replace values

I have a scenario that I need to open a word document and find values in curly braces like {Foods $100} and update only the amount. How will be able to replace the value “$100” with different value and leaving the rest as it is?
Note: the amount changes time to time I don’t know what amount to search for ,but the value {Foods } will stay the same,so what ever amount is in the curly brace need to be updated with excel cell value

Thank you in advance

@Redwan_Hussien - You can try like this…

Read your Word File as text and using Regex.replace update the value.

Regex Replace Properties…StrWordText is the output from the ReadText activity

Regex Pattern used


Note: Only thing I am not sure, if you write back the text to word line will it retain the same format or not. I guess it will not.

Here instead of $200…you can read the excel file rows and pass it…

1 Like

Thank you for your response.
What text did you add in read text file ?
I can read the “Foods” but not the amount since it changes time to time?

@Redwan_Hussien - You could have tried adding that activity, then you should have got an idea…

Input to Read Text acitivity is your word doc, so it read the entire word docs…and search for the pattern…and capture $100 value…it’s all dynamic…

Check this link for the Regex Pattern…

Please find the starter help here…FindandReplaceWord_Regex.zip (69.5 KB)

Thank you so much. It works. Any idea how I can update the amount in Word.I used Replace Text in Document activity and pass the Replace activity output in "search for "field and the amount in 'replace"field to update the value,but still I am not able to achieve that.

@Redwan_Hussien - I am not sure whether this can be achieved in Replace Text activity…Because you have to replace just the amount within the {Foods $100} this text.

For this you have to use either regex or string.split. For both these, you have to pass the text as an input first. Without that Regex and String.split method method won’t work.