Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove HTML comments with Regex, in Javascript
    primarykey
    data
    text
    <p>I've got some ugly HTML generated from Word, from which I want to strip all HTML comments.</p> <p>The HTML looks like this:</p> <pre class="lang-none prettyprint-override"><code>&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;o:OfficeDocumentSettings&gt; &lt;o:RelyOnVML/&gt; &lt;o:AllowPNG/&gt; &lt;/o:OfficeDocumentSettings&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:WordDocument&gt; &lt;w:View&gt;Normal&lt;/w:View&gt; &lt;w:Zoom&gt;0&lt;/w:Zoom&gt; &lt;w:TrackMoves/&gt; &lt;w:TrackFormatting/&gt; &lt;w:HyphenationZone&gt;21&lt;/w:HyphenationZone&gt; &lt;w:PunctuationKerning/&gt; &lt;w:ValidateAgainstSchemas/&gt; &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt; &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt; &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt; &lt;w:DoNotPromoteQF/&gt; &lt;w:LidThemeOther&gt;NO-BOK&lt;/w:LidThemeOther&gt; &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt; &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt; &lt;w:Compatibility&gt; &lt;w:BreakWrappedTables/&gt; &lt;w:SnapToGridInCell/&gt; &lt;w:WrapTextWithPunct/&gt; &lt;w:UseAsianBreakRules/&gt; &lt;w:DontGrowAutofit/&gt; &lt;w:SplitPgBreakAndParaMark/&gt; &lt;w:EnableOpenTypeKerning/&gt; &lt;w:DontFlipMirrorIndents/&gt; &lt;w:OverrideTableStyleHps/&gt; &lt;/w:Compatibility&gt; &lt;m:mathPr&gt; &lt;m:mathFont m:val="Cambria Math"/&gt; &lt;m:brkBin m:val="before"/&gt; &lt;m:brkBinSub m:val="&amp;#45;-"/&gt; &lt;m:smallFrac m:val="off"/&gt; &lt;m:dispDef/&gt; &lt;m:lMargin m:val="0"/&gt; &lt;m:rMargin m:val="0"/&gt; &lt;m:defJc m:val="centerGroup"/&gt; &lt;m:wrapIndent m:val="1440"/&gt; &lt;m:intLim m:val="subSup"/&gt; &lt;m:naryLim m:val="undOvr"/&gt; &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt; </code></pre> <p>..and the regex I am using is this one</p> <pre><code>html = html.replace(/&lt;!--(.*?)--&gt;/gm, "") </code></pre> <p>But there seems to be no match, the string is unchanged.</p> <p>What I am missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload