Problem to replace special characters in a table

Hello,
I have a problem to fill the table dynamically.
When the table is filled, I clean the line.
I delete all \r and space in the cell when this one have no data.
When I get the row, I have this text in my range :
"\aCell with Data\r\a\a\a\r\r\r \r\r\r \r\a\a\r\r\r \r\r\r \r\a\a\r\r\r \r\r\r \r\a\a\r\r\r \r\r\r \r\a\a\r\r\r \r\r\r \r\a\a\r\r\r \r\r\r \r\a\a"

So when I clean I apply this regex:
Regex regexCleanCell = new Regex(string.Format(CultureInfo.InvariantCulture, @"{0}({1}|{2})+{0}", ControlChar.Cell, ControlChar.Cr, ControlChar.SpaceChar), RegexOptions.IgnoreCase);
if (regexCleanCell.IsMatch(newRow.Range.Text))
{
newRow.Range.Replace(regexCleanCell, ControlChar.Cell + ControlChar.Cell, new FindReplaceOptions());
}

I match with the regex (6 times) but when I would like replace in the range with the function Replace I have nothing (no replace).

Where is my problem? What am I doing wrong?
Regards


Hi there,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that you used to generate the document.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information on this along with code example. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.