Hi All,
Its very urgent.
I am facing an issue with removing <style>......</style> from the HTML text. I want to remove all the text/special character/all the property between style tag.
<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style> <!-- @font-face {font-family:"Cambria Math"} @font-face {font-family:Calibri} p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif} span.EmailStyle17 {font-family:"Calibri",sans-serif; color:windowtext} .MsoChpDefault {font-family:"Calibri",sans-serif} @page WordSection1 {margin:72.0pt 72.0pt 72.0pt 72.0pt} div.WordSection1 {} --> </style></head><body style="word-wrap:break-word"><div class="WordSection1"><p class="MsoNormal">Body of the email</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>BOLD text</b></p><p class="MsoNormal"><b> </b></p><p class="MsoNormal"><b></b></p></div></body></html>
Thanks in advance.
Discussion posts and replies are publicly visible
Did you try to use a regular expression? The following pattern removes the style section:
regexreplaceall("<style>[\s\S]*?</style>", ri!html, "")
Not working...
I want to remove comments added in HTML text as mention above.
<!-- @font-face {font-family:"Cambria Math"} @font-face {font-family:Calibri} p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif} span.EmailStyle17 {font-family:"Calibri",sans-serif; color:windowtext} .MsoChpDefault {font-family:"Calibri",sans-serif} @page WordSection1 {margin:72.0pt 72.0pt 72.0pt 72.0pt} div.WordSection1 {} -->
Then, just adapt the basic pattern to your needs.
regexreplaceall("<!--[\s\S]*?-->", ri!html, "")
BTW, why are you doing this? Do you try to edit HTML in Word? If yes, it might be easier to do that in a real text editor like Notepad++.
Not worked.
This HTML Snippet is a response from 3rd Party we are converting in a PDF document. The above highlighted Snippet appears as text in the document.
What exactly do you mean with "Not worked" ?
I see the following output:
<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style> </style></head><body style="word-wrap:break-word"><div class="WordSection1"><p class="MsoNormal">Body of the email</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>BOLD text</b></p><p class="MsoNormal"><b> </b></p><p class="MsoNormal"><b></b></p></div></body></html>
It is working. Thank you for your help.