preg替换标签之间的内容以及标签

时间:2017-04-19 07:33:35

标签: php regex preg-replace

我有正则表达式,https://regex101.com可以帮我搜索xml标签和它们之间的内容,但是当我在preg_replacepreg_match中使用此正则表达式时,它会发出警告, 分隔符不得为字母数字或反斜杠。我应该如何编辑此命令以使其正常工作?我必须删除它们之间的标签和内容。

正则表达式是:

\<mc\:AlternateContent\>[\s\S]*?\<\/mc:AlternateContent\>

preg replace(正则表达式在常量内):

preg_replace(self::REGEX_PATTERN_ALTERNATE_CONTENT, '', $paragraph->asXML());

XML:

  <mc:AlternateContent>
                    <mc:Choice Requires="wps">
                        <w:drawing>
                            <wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0"
                                       relativeHeight="251666432" behindDoc="0" locked="1" layoutInCell="0"
                                       allowOverlap="1">
                                <wp:simplePos x="0" y="0"/>
                                <wp:positionH relativeFrom="page">
                                    <wp:posOffset>6387465</wp:posOffset>
                                </wp:positionH>
                                <wp:positionV relativeFrom="page">
                                    <wp:posOffset>2776855</wp:posOffset>
                                </wp:positionV>
                                <wp:extent cx="227965" cy="635"/>
                                <wp:effectExtent l="15240" t="14605" r="13970" b="13335"/>
                                <wp:wrapNone/>
                                <wp:docPr id="8" name="Přímá spojnice 8"/>
                                <wp:cNvGraphicFramePr>
                                    <a:graphicFrameLocks
                                            xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
                                </wp:cNvGraphicFramePr>
                                <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                                    <a:graphicData
                                            uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
                                        <wps:wsp>
                                            <wps:cNvCnPr>
                                                <a:cxnSpLocks noChangeShapeType="1"/>
                                            </wps:cNvCnPr>
                                            <wps:spPr bwMode="auto">
                                                <a:xfrm>
                                                    <a:off x="0" y="0"/>
                                                    <a:ext cx="227965" cy="635"/>
                                                </a:xfrm>
                                                <a:prstGeom prst="line">
                                                    <a:avLst/>
                                                </a:prstGeom>
                                                <a:noFill/>
                                                <a:ln w="12700">
                                                    <a:solidFill>
                                                        <a:srgbClr val="000000"/>
                                                    </a:solidFill>
                                                    <a:round/>
                                                    <a:headEnd/>
                                                    <a:tailEnd/>
                                                </a:ln>
                                                <a:extLst>
                                                    <a:ext uri="{909E8E84-426E-40DD-AFC4-6F175D3DCCD1}">
                                                        <a14:hiddenFill
                                                                xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main">
                                                            <a:noFill/>
                                                        </a14:hiddenFill>
                                                    </a:ext>
                                                </a:extLst>
                                            </wps:spPr>
                                            <wps:bodyPr/>
                                        </wps:wsp>
                                    </a:graphicData>
                                </a:graphic>
                                <wp14:sizeRelH relativeFrom="page">
                                    <wp14:pctWidth>0</wp14:pctWidth>
                                </wp14:sizeRelH>
                                <wp14:sizeRelV relativeFrom="page">
                                    <wp14:pctHeight>0</wp14:pctHeight>
                                </wp14:sizeRelV>
                            </wp:anchor>
                        </w:drawing>
                    </mc:Choice>
                    <mc:Fallback>
                        <w:pict>
                            <v:line w14:anchorId="4CB34296" id="Přímá spojnice 8" o:spid="_x0000_s1026"
                                    style="position:absolute;z-index:251666432;visibility:visible;mso-wrap-style:square;mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:page;mso-position-vertical:absolute;mso-position-vertical-relative:page;mso-width-percent:0;mso-height-percent:0;mso-width-relative:page;mso-height-relative:page"
                                    from="502.95pt,218.65pt" to="520.9pt,218.7pt"
                                    o:gfxdata="UEsDBBQABgAIAAAAIQC2gziS/gAAAOEBAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbJSRQU7DMBBF&#xA;90jcwfIWJU67QAgl6YK0S0CoHGBkTxKLZGx5TGhvj5O2G0SRWNoz/78nu9wcxkFMGNg6quQqL6RA&#xA;0s5Y6ir5vt9lD1JwBDIwOMJKHpHlpr69KfdHjyxSmriS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XYueG1sUEsFBgAAAAAEAAQA8wAAAJEFAAAAAA==&#xA;"
                                    o:allowincell="f" strokeweight="1pt">
                                <w10:wrap anchorx="page" anchory="page"/>
                                <w10:anchorlock/>
                            </v:line>
                        </w:pict>
                    </mc:Fallback>
                </mc:AlternateContent>

0 个答案:

没有答案