Find-replace html tag with new tag but preserve text

Is there any custom config setting/pattern that allows me to find markup like this:
<span class="title3">Sample title</span>

and replace with this:

<h3>Sample title</h3>

Would be super useful for a use case I’m facing down.

That’s not possible at the moment, I’m afraid. You could use find_string and replace_string but that wouldn’t help with the closing span (would replace all closing span elements).

Thanks for responding.

Checking back on this question, should there be any change…

I need to be able to remove ALL <table> tags in document, regardless of attributes, which may differ from one tag to the next.

So replace these, and any variations, with nothing:

<table class="layout" style="table-layout: fixed;" width="100%" border="0" cellpadding="0" cellspacing="0">
<table class="divider" style="width: 93%; height: 1px;" cellpadding="0" cellspacing="0" border="0">

Hi there, you can use XPath to remove elements you don’t want in a site config file.

strip: [XPath expression]

To remove all table elements, the XPath expression would be:

strip: //table

Hi.

I probably should have better explained my situation, since I’m not looking to eliminate the entire table, just the <table> tags.

For example, how can I preserve just the <p> elements nested in these tables?

<table class="foo">
  <tr>
    <td>
       <p>some text</p>
    </td>
  </tr>
</table>

<table class="bar">
  <tr>
    <td>
       <p>some text</p>
    </td>
  </tr>
</table>

strip: //table will remove everything. And find/replace using XPath does not support regx.

The only thing I could come up with is trying to remove the <table> tags. This would work for me since the WYSIWYG editor this is integrated with will remove the entire table structure if the <table> tag is missing, leaving just the <p>s.

note: I can’t target the tables specifically by any attribute, such as class, as the documents I’m working with have several nested tables and the attribute lists change frequently.

Ideally, I would like to replace ANY table tag with nothing.

Ah I see, thanks for the clarification. There’s still no great way to do this at the moment with Full-Text RSS. We’ll have more options for such operations in the future.

There are some hacky ways using string replacement that can sometimes work.

If you can’t replace the entire table tag because of changing attributes in the middle, you can sometimes string-match the beginning and ending parts (or some surrounding string that doesn’t change but always appears before/after the table tag). If you can see some kind of pattern there, you can use Full-Text RSS’s replace_string or find_string/replace_string to place them in a HTML comment, which should cause your WYSIWYG editor to trigger the same cleanup you mentioned you see when the table tag is absent:

replace_string(<table): <!--
replace_string(cellpadding="0" cellspacing="0">): -->
replace_string(cellspacing="0" border="0">): -->

or

find_string: <table
replace_string: <!--
find_string: cellpadding="0" cellspacing="0">
replace_string: -->

You can use the same method to wrap the tag in another HTML tag with a style attribute set to “display:none” that will trigger Full-Text RSS’s cleanup and remove the element with that style attribute:

replace_string(<table): <div style="display:none;"><table
replace_string(cellpadding="0" cellspacing="0">): ></div>

you could also try to rename the table-tag to something invalid. Don’t know if the content between persists then:

find_string: <table
replace_string: <text

find_string: </table
replace_string: </text
1 Like

HolgerAusB’s recommendation has so far been good in my testing. Thanks all for the help on this.

1 Like