Search for Multiline patterns – OpenXmlRegex

Home Forums Open-Xml-PowerTools Search for Multiline patterns – OpenXmlRegex

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  meronf 8 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3300

    meronf
    Participant

    Hello,
    Is there an option to replace multiline string that match a pattern that starts with ** and ends with ** with empty string. The content between the ** can contains any type of content, paragraphs, line brakes, images, etc. and should dropped from the document in case it surrounds with **.

    I tried the OpenXmlRegex with the following pattern:
    regex = new Regex((@”\*\*(.*)(\n)?(.*)?\*\*”), RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant);

    But it works only for text content in the same line.

    Any idea how can I achieve such request?

    Thanks,
    Meron

    #3302

    Eric White
    Keymaster

    Hi,

    This is, unfortunately, not a feature of the OpenXmlRegex class. It is the most requested feature, but I have not had the opportunity to enhance it to enable this feature.

    It is a pretty complicated piece of code to write. Have you watched the screen-casts on OpenXmlRegex? The second screen-cast walks through the algorithm currently implemented for OpenXmlRegex. Unfortunately, that algorithm is not suitable for execution over an entire document – breaking an entire document up into runs of a single character results in too much memory usage. Therefore, OpenXmlRegex does text replacement on a single paragraph at a time.

    I have contemplated another approach that would use far less memory, but have yet to prove out this approach.

    Cheers, Eric

    #3304

    meronf
    Participant

    Thanks Eric.

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

You must be logged in to reply to this topic.