Unwanted spaces when using "replace text in word document"

The task is to read text from PDF, extract only the relevant content, and lastly, replace some text within a word document with this new extracted relevant data. The workflow adopted by me -
“Read PDF Text” to get the pdf data in a string format - Everything works fine.
Use “matches” and configure regex to extract relevant content - successfully able to do it.
Use “Replace text in Document” to replace a string within word doc with the new extracted data - ISSUE LIES HERE!!!


As you can see in the attached snapshots, words “accompanying” and “mental” are at the very end of sentence within PDF. When adding content to word, that is exactly where there are unwanted spaces. Please help!!!


Try this