Replace string between two words

HI All,

I have a sentence in which I want to replace below string.
i/p- " Company Technische Cancellations [Company - Air France KLM]’ .This is Testing."

o/p- " Company Technische Cancellations [Company -*]’ .This is Testing. "

i tried with substring to find index of " - " and append " *]’ .This is Testing." . BUt it is not a correct way. because sometime " - " came multiple time or append text is also changing

Try this
inputstring.replace(“regexpattern”,“*”)
insert the regex pattern present in the imageregex

1 Like

thanks i have one more concern if this “Company Technische Cancellations” also dynamic .
that is only constant thing in a string is Company Technische Cancellations [Company - Air France KLM**]’** .This is Testing

Then remove all the text prior to “[Company” and replace it.

Does the bot need to understand the pattern and replace the string?
Or do you know what is going to be replaced? (from other variables or so?)

In this sentence

  • do you know that the contents to be replaced are Company Technische Cancellations and Air France KLM

if this is the case then it becomes a lot simpler to replace