Replace Text in between 2 text (second instance)

I am using below 2 variables to replace text in between. and I am getting the error - Too many )'s
I need the second occurrence of the text. Can someone help me edit this variable to pick second instance
str_output =

where str_input =

Hi @Padmashree_Sandeep ,

Could you try this instead?


Kind Regards
Ashwin A.K

Try this expression



Thanks ! I followed variable from this link that has 2 closing brackets. by removing it the error is gone. But this is not complete solution.
Let me explain my case. I need to replace content in word document under header 2 as Confidential. Since these headers are there in Index page as well, this will be second occurrence

  1. Key considerations
    Impact from COVID-19
    Company took prudent steps to manage its portfolio and arrangements with lenders through the COVID-19 pandemic

  2.  Transaction History

I assume the above variable is returning bullion response Match or no Match. Due to this I am not able to equate it to string (Assign activity) Can you help me how to get this text replaced

I am currently using but this is not working
assign activity
Str_Output = System.Text.RegularExpressions.Regex.Match(str_input,"(?>=2. Key considerations).*(?=3. Transaction History)")

Replace Text in document
Search for Str_Output
Replaced with “Confidential”

If Possible can you share sample docx?



Can you try the following expression?

Str_Output = System.Text.RegularExpressions.Regex.Match(str_input,"(?<=2\. Key considerations)[\s\S]*?(?=3\. Transaction History)").Value


Str_output = System.Text.RegularExpressions.Regex.Match(str_input,"(?<=2\. Key considerations).*?(?=3\. Transaction History)",System.Text.RegularExpressions.RegexOptions.Singleline).Value


I cannot upload anything due to compliance issue. but I have shared the sample text above. same can be added to word doc for sample

Above function helped me in finding the text in between. I will add the actual code that I have added in next post. Now I want to replace this string with word “Confidential”

I have used string manipulation function to search the string in huge word document. But this is around 3500 characters. When I use “Replace Text in Document” Activity, I am getting error that I can replace only upto 256 characters.

Can you help me

  1. with function that splits the text dynamically in batches of 250 characters
  2. replace first 250 characters with term “Confidential” and rest of them with blank space or Null

Hi @Padmashree_Sandeep ,

To confirm the operation, you would want to replace the Text in the Word Document?

Is it only the first 250 Characters of the Document that you want to replace?

If you could provide a sample of what is the Input and what should be it’s expected output, we would be able to help you faster.