Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

REPLACE a certain string in a certain field

Hi there,

I have hundreds of  text strings in a specific field of a certain table with none or exactly these two "words": <semantics> and  </semantics>

I want to REPLACE the whole string presented, BUT excluding the two above "words" present at them, if it is the case.

Example: one possible data contained in the field is:

<p>Question 06: If  <math>   <semantics>    <mrow>     <mtext>&#8201;</mtext><mtext>&#8201;</mtext><mi>x</mi><mo>+</mo><mi>y</mi><mo>=</mo><mi>a</mi><mtext>&#8201;</mtext><mtext>&#8201;</mtext><mtext>&#8201;</mtext>    </mrow>    <annotation encoding='MathType-MTEF'>MathType@MTEF@5@5@+=feaagCart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbwvMCKfMBHbqedmvETj2BSbqefm0B1jxALjhiov2DaerbuLwBLnhiov2DGi1BTfMBaebbnrfifHhDYfgasaacH84rpq0xbbf9q8WrFfeuY=Hhbbf9v8qqGqFr0xc9LqFj0lXxbba9Lqpepi0xhr=Fc9vqpeuj0lXdb9GqFj0dd9qqaqpi0xe9Gq=Fhrpe0dc8meaabaqaciaacaGaaeqabaWaaqaafaaakeaacaaMc8UaaGPaVlaadIhacqGHRaWkcaWG5bGaeyypa0JaamyyaiaaykW7caaMc8UaaGPaVdaa@46B9@</annotation>   </semantics>  </math> </p>

And I want to have it substituted by this one:

<p>Question 06: If  <math>    <mrow>     <mtext>&#8201;</mtext><mtext>&#8201;</mtext><mi>x</mi><mo>+</mo><mi>y</mi><mo>=</mo><mi>a</mi><mtext>&#8201;</mtext><mtext>&#8201;</mtext><mtext>&#8201;</mtext>    </mrow>    <annotation encoding='MathType-MTEF'>MathType@MTEF@5@5@+=feaagCart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbwvMCKfMBHbqedmvETj2BSbqefm0B1jxALjhiov2DaerbuLwBLnhiov2DGi1BTfMBaebbnrfifHhDYfgasaacH84rpq0xbbf9q8WrFfeuY=Hhbbf9v8qqGqFr0xc9LqFj0lXxbba9Lqpepi0xhr=Fc9vqpeuj0lXdb9GqFj0dd9qqaqpi0xe9Gq=Fhrpe0dc8meaabaqaciaacaGaaeqabaWaaqaafaaakeaacaaMc8UaaGPaVlaadIhacqGHRaWkcaWG5bGaeyypa0JaamyyaiaaykW7caaMc8UaaGPaVdaa@46B9@</annotation>  </math> </p>

(Of course the bold ... is present only here, for the sake of clearness.)

Thanks,
fskilnik.
0
fskilnik
Asked:
fskilnik
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
update table
set field = replace(replace(field, '<semantics>', ''), '</semantics>', '')

to test it out and make sure this is what you want:

select replace(replace(field, '<semantics>', ''), '</semantics>', '')
from table
0
 
fskilnikAuthor Commented:
Perfect, Kyle! Thanks a lot.

Regards,
fskilnik.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now