Remove all CSS Classes from String Using Hugo's replaceRE?

So I am using Hugo’s data features and a CSV that contains the following HTML:

<div class="field-item even">
    <p>A key consideration for IT decision-makers when purchasing an IP Telephony and unified communications solution is the Total Cost of Ownership (TCO).</p>
    <p>In a new webinar, “How to Evaluate Total Cost,” we drill down on the TCO, which goes beyond unit costs as the primary metric of consideration, to include initial implementation, recurring cost, bundled feature set, and system performance.</p>
    <p>The free Webinar features an Lorem Ipsum survey of real-world TCO experienced by 485 users of IP telephony and legacy Time Division Multiplexing telephony. &nbsp;Andrew Borg, Acme's research director for enterprise mobility and collaboration, outlines the survey’s results, which show that users of Acme solutions experienced the lowest TCO.</p>
    <p>Also featured in the Webinar are first-hand reports from Jonathan Schiller, CIO of Minnwest Bank and Glenn Rogers, CIO of Girls Scouts of Northern California, both of whom explain how TCO considerations helped persuade them to choose Acme solutions.</p>
    <p>The Webinar also includes a review of Acme IP telephony and UC capabilities, as well as a lively Q&amp;A session. Check it out.</p>
    <div style="width: 394px;display:block;margin:0 auto;">
        <a href="/wp-content/uploads/2013/06/aberdeen.png"></a>
        <div id="file-4138" class="file file-image file-image-png">
            <a href="/wp-content/uploads/2013/06/aberdeen.png">
                <h2 class="element-invisible">Acme</h2>
            </a>
            <div class="content">
                <img alt="The Acme survey showed users of blahblahblah solutions had reduced costs in every category." height="288" width="384" class="media-image  wp-image-5974  media-element file-media-large" src="/sites/default/files/wp-content/uploads/2013/06/acme.png">
            </div>
        </div> The Aberdeen survey showed users of blahblahblah solutions had reduced costs in every category.
    </div>
</div>

I would like to use safeHTML and replaceRE to clean all id and class declarations or, at the very least, definitely remove all inline style tags since this will conflict with my CSS that I’m using. The ideal result would be as follows:

<div>
    <p>A key consideration for IT decision-makers when purchasing an IP Telephony and unified communications solution is the Total Cost of Ownership (TCO).</p>
    <p>In a new webinar, “How to Evaluate Total Cost,” we drill down on the TCO, which goes beyond unit costs as the primary metric of consideration, to include initial implementation, recurring cost, bundled feature set, and system performance.</p>
    <p>The free Webinar features an Lorem Ipsum survey of real-world TCO experienced by 485 users of IP telephony and legacy Time Division Multiplexing telephony. &nbsp;Andrew Borg, Acme's research director for enterprise mobility and collaboration, outlines the survey’s results, which show that users of Acme solutions experienced the lowest TCO.</p>
    <p>Also featured in the Webinar are first-hand reports from Jonathan Schiller, CIO of Minnwest Bank and Glenn Rogers, CIO of Girls Scouts of Northern California, both of whom explain how TCO considerations helped persuade them to choose Acme solutions.</p>
    <p>The Webinar also includes a review of Acme IP telephony and UC capabilities, as well as a lively Q&amp;A session. Check it out.</p>
    <div>
        <a href="/wp-content/uploads/2013/06/aberdeen.png"></a>
        <div>
            <a href="/wp-content/uploads/2013/06/aberdeen.png">
                <h2>Acme</h2>
            </a>
            <div class="content">
                <img alt="The Acme survey showed users of blahblahblah solutions had reduced costs in every category." height="288" width="384" src="/sites/default/files/wp-content/uploads/2013/06/acme.png">
            </div>
        </div> The Aberdeen survey showed users of blahblahblah solutions had reduced costs in every category.
    </div>
</div>

Any help would be greatly appreciated. Thanks!

something like this:

 | replaceRE `[ ]*(id|class|style)="[^"]*"` ""  | 

optional spaces
id or class or style followed by ="
optional characters not equal "
followed by a "

replace with nothing (= delete).

Not matched over new lines (as given in your example)

to clean all id and class declarations

Why keep

<div class="content">

in your ideal result ?

1 Like