3

I want to replace the following chunks of html contained in a cell:

Original

<table class="generic">

Replacement

<table class="data-table" id="product-attribute-specs-table">

Original

<h2>Especificaciones</h2> <p></p>

Replacement

Nothing - delete this chunk of html code

This is what I´ve got so far:

=SUBSTITUTE(Results_ES!K5, "<h2>Especificaciones</h2> <p></p>", "")

...but I don´t know how to substitute the other chunk because it has double quotes.

=SUBSTITUTE(Results_ES!K5, "<h2>Especificaciones</h2> <p></p>", "", "<table class="generic">", "<table class="data-table" id="product-attribute-specs-table">")

I read that I could use CHAR(34) to escape double quotes but I don´t know how to use it in this context.

2 Answers 2

2

String concatenation operator &, for example:

"<table class=" & CHAR(34) & "generic" & CHAR(34) & ">"

Or, the CONCATENATE function:

CONCATENATE("<table class=",CHAR(34),"generic",CHAR(34),">")
3
  • =SUBSTITUTE(Results_ES!K5, "<h2>Especificaciones</h2> <p></p>", "", "<table class=" & CHAR(34) & "generic" & CHAR(34) & ">", "<table class=" & CHAR(34) & "data-table" & CHAR(34) & "id=" & CHAR(34) & "product-attribute-specs-table" & CHAR(34) & ">")
    – Pablo
    Commented Jun 23, 2015 at 23:25
  • But Google Sheets says: Error Wrong number of arguments to SUBSTITUTE. Expected between 3 and 4 arguments, but got 5 arguments.
    – Pablo
    Commented Jun 23, 2015 at 23:26
  • 1
    You can't replace both strings in a single function call, you will need to nest two calls to the SUBSTITUTE function. ie. =SUBSTITUTE(SUBSTITUTE(Results_ES!K5, ....
    – MrWhite
    Commented Jun 23, 2015 at 23:32
2

For the record, this is what I've done:

=SUBSTITUTE(SUBSTITUTE(Results_ES!K5, "<h2>Especificaciones</h2> <p></p>", ""), "<table class=" & CHAR(34) & "generic" & CHAR(34) & ">", "<table class=" & CHAR(34) & "data-table" & CHAR(34) & " id=" & CHAR(34) & "product-attribute-specs-table" & CHAR(34) & ">")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.