OpenXmlRegex Replace content using replacement pattern

Home Forums Open-Xml-PowerTools OpenXmlRegex Replace content using replacement pattern

This topic contains 1 reply, has 1 voice, and was last updated by  ajan 7 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4422

    ajan
    Participant

    Hi, trying to use OpenXmlRegex I started with the Example TextReplace01.cs, especially the replacement with pattern, because this is what I need. But:

                    // Replace content using replacement pattern (paragraph 18)
                    content = xDoc.Descendants(W.p).Skip(17).Take(1);
                    regex = new Regex($"({leftDoubleQuotationMarks})(video)({rightDoubleQuotationMarks})");
                    count = OpenXmlRegex.Replace(content, regex, "$1audio$3", null, true, "John Doe");
                    Console.WriteLine("Example #20 Replaced: {0}", count);
    

    gives me paragraph 18 looking like this:

    The first $1audio$3 is like the second $1audio$3 but not like the third ‘video’.

    wich is obviously not what I have expected. Have I got something wrong?

    #4427

    ajan
    Participant

    Found the solution: after pulling and building the newest Version from repository it worked fine. The nuget Version seems not to have this option.
    Great work!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.