{"id":1980,"date":"2016-02-03T15:56:23","date_gmt":"2016-02-03T15:56:23","guid":{"rendered":"http:\/\/www.ericwhite.com\/home2\/bm8qcmjy\/public_html\/blog\/?page_id=1980"},"modified":"2016-03-22T23:12:18","modified_gmt":"2016-03-22T23:12:18","slug":"how-the-openxmlregex-class-works","status":"publish","type":"page","link":"https:\/\/www.ericwhite.com\/blog\/how-the-openxmlregex-class-works\/","title":{"rendered":"How the OpenXmlRegex Class Works"},"content":{"rendered":"<p><span class=\"Back\"><a class=\"Back\" href=\"https:\/\/www.ericwhite.com\/blog\/openxmlregex-developer-center\/\">Return to the<br \/>OpenXmlRegex Developer Center<\/a><\/span>In a <a href=\"http:\/\/openxmldeveloper.org\/home2\/bm8qcmjy\/public_html\/blog\/b\/openxmldeveloper\/archive\/2014\/07\/22\/search-and-replace-content-in-docx-pptx-using-regular-expressions.aspx\">previous blog post<\/a>, I introduced a new class (OpenXmlRegex) that is in PowerTools for Open XML. &nbsp;This class enables you to search for content via a regular expression, and if it finds the content, you can optionally replace it with new content. &nbsp;Further, this class supports revision tracking. &nbsp;It can search through content that contains revision tracking, and it can optionally introduce revision tracking into the document as it replaces content.<\/p>\n<p>The OpenXmlRegex class is pretty useful in a variety of scenarios. &nbsp;You could, for instance, define specific patterns such as &lt;# KeyWord #&gt;, search for those patterns, and then replace them with customized content based on the key word. &nbsp;Another interesting scenario is where you want to search for content that doesn&#39;t meet your corporate standards. &nbsp;You might have very specific ways to refer to certain products, or to divisions of your enterprise, and you might want to write a utility that searches for a variety of ways that document authors make incorrect references.<\/p>\n<p>In the previous screen-cast (<a href=\"http:\/\/openxmldeveloper.org\/home2\/bm8qcmjy\/public_html\/blog\/b\/openxmldeveloper\/archive\/2014\/07\/22\/search-and-replace-content-in-docx-pptx-using-regular-expressions.aspx\">Search and Replace Content in DOCX, PPTX using Regular Expressions<\/a>), I walked through the API, and explained some of the more interesting aspects of the behavior of the class. &nbsp;In the following screen-cast, I explain the algorithm. &nbsp;This will be interesting to students of Open XML and document formats in general. &nbsp;It will be interesting to anyone who is porting this code to another platform such as Java, C++, or JavaScript. &nbsp;And finally, it will be interesting to me in a few years &#8211; it will remind me of how the code works!<\/p>\n<p><iframe loading=\"lazy\" title=\"OpenXmlRegex Internals\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/ShtRj5MHK9I?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>Cheers, Eric White<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Return to theOpenXmlRegex Developer CenterIn a previous blog post, I introduced a new class (OpenXmlRegex) that is in PowerTools for Open XML. &nbsp;This class enables you to search for content via a regular expression, and if it finds the content, you can optionally replace it with new content. &nbsp;Further, this class supports revision tracking. &nbsp;It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_s2mail":"","footnotes":""},"class_list":["post-1980","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/1980","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/comments?post=1980"}],"version-history":[{"count":3,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/1980\/revisions"}],"predecessor-version":[{"id":3248,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/1980\/revisions\/3248"}],"wp:attachment":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/media?parent=1980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}