Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何读取js中嵌入的html字符串?_Javascript_Html_Html Parsing - Fatal编程技术网

Javascript 如何读取js中嵌入的html字符串?

Javascript 如何读取js中嵌入的html字符串?,javascript,html,html-parsing,Javascript,Html,Html Parsing,我有一个字符串,需要转换成可读的形式。预期输出附在底部。这基本上是在js中读取htmlstring。我看了很多文章,但没有找到什么东西 str = "<p><!-- [if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--> <!-

我有一个字符串,需要转换成可读的形式。预期输出附在底部。这基本上是在js中读取
html
string。我看了很多文章,但没有找到什么东西

str = "<p><!-- [if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:AllowPNG/>
 </o:OfficeDocumentSettings>
</xml><![endif]--> <!-- [if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:PunctuationKerning/>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF/>
  <w:LidThemeOther>EN-GB</w:LidThemeOther>
  <w:LidThemeAsian>ZH-CN</w:LidThemeAsian>
  <w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:OverrideTableStyleHps/>
  </w:Compatibility>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math"/>
   <m:brkBin m:val="before"/>
   Name="index heading"/>
  <w:LsdException Locked="false" Priority="35" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="caption"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="table of figures"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="envelope address"/>
   Name="Table Columns 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Contemporary"/>
   Name="Table Web 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Balloon Text"/>
  <w:LsdException Locked="false" Priority="39" Name="Table Grid"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Theme"/>
  <w:LsdException Locked="false" SemiHidden="true" Name="Placeholder Text"/>
  <w:LsdException Locked="false" Priority="1" QFormat="true" Name="No Spacing"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 6"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 6"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 6"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Mention"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Smart Hyperlink"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Hashtag"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Unresolved Mention"/>
 </w:LatentStyles>
</xml><![endif]--></p>
<h3 class="MsoNormal" style="margin-top: 0px; font-family: 'Open Sans', sans-serif; font-size: 13px; background-color: #ffffff; margin-bottom: 5px !important;">&nbsp;</h3>
<h3><img src="http://lms-286-liveshared.edcastcloud.com:80/asset-v1:thomson-foundation+6663jn04+self-paced+type@asset+block@CPDtick.jpg" alt="" width="116" height="106" /></h3>
<p>This course carries&nbsp;4 hours of Continuing Professional Development (CPD) credits.&nbsp;</p>
<p>&nbsp;</p>
<p>In support of the Journalism Now Scholar Programme, for a limited time, there is no charge for the course certificate.&nbsp;&nbsp;</p>
<p>&nbsp;</p>
<p><strong style="font-size: 14px;">COURSE OVERVIEW</strong><span style="font-size: 14px;">&nbsp;</span></p>
<p>This course will help give your use of social media a journalistic purpose.&nbsp; You'll learn how to find good stories, whether you're using Facebook, Twitter, Instagram, or any other form of social media. Once you've completed the course, you will be able to understand each of the social media platforms - they all have their own system which you will be able to get to grips with and you will discover how to refine your searches so that you get the information you need more easily.&nbsp; The course will help you become a good 'social listener' by giving you the best hashtags to use, as well as the best keywords.</p>
<p>&nbsp;</p>
<p>"<em>The content is really good, I enjoyed it because I went in without knowing much but finished the course more knowledgeable. I learnt a lot of things.</em>" <strong>Pheladi from South Africa</strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>WHAT YOU WILL LEARN</strong></p>
<p>&bull; How to use SOCIAL MEDIA to FOLLOW breaking news and to FIND STORIES as well as sources.&nbsp;</p>
<p>&bull; How to use ADVANCED SEARCH TECHNIQUES as a tool for finding information and locating experts.</p>
<p>&bull; How to use social media to verify if a BREAKING NEWS story is true.</p>
<p>&bull; How to establish the ORIGIN OF PHOTOGRAPHS and how to verify them.</p>
<p>&nbsp;</p>
<p><strong>MEET YOUR INSTRUCTORS</strong></p>
<p>&nbsp;<img style="display: block; margin-left: auto; margin-right: auto;" src="http://lms-286-liveshared.edcastcloud.com:80/asset-v1:thomson-foundation+6663jn04+self-paced+type@asset+block@JN04_-_Trainer.png" alt="" width="387" height="217" /></p>
<p><strong>SUE LLEWELLYN</strong> is your course instructor. For the past 10 years, Sue has worked as a trainer for thousands of journalists, teaching them how to use social media. Before that, she was a journalist for 15 years in the BBC Newsroom.&nbsp;</p>
<p>&emsp;</p>
<p>&nbsp;<img style="display: block; margin-left: auto; margin-right: auto;" src="http://lms-286-liveshared.edcastcloud.com:80/asset-v1:thomson-foundation+6663jn04+self-paced+type@asset+block@JN04_-_Experts.jpeg" alt="" width="387" height="129" /></p>
<p>Helping Sue is a team of experts (from left to right):</p>
<ul>
<li><strong>Matt Cooke</strong> works at the Google News Lab, Matt is an ex-BBC newsman who is a specialist in digital storytelling.&nbsp;</li>
<li><strong>Anne-Marie Tomchak</strong> is the former presenter of BBC Trending who's now UK editor of Mashable.&nbsp;</li>
<li><strong>Fred Mwasa</strong> is Deputy Editor-in-Chief at Kigali Today.&nbsp; Fred has a massive following on Twitter, with the highest number of followers for journalists in Rwanda.&nbsp;</li>
</ul>
<p>&nbsp;</p>
<p><strong>COURSE OUTLINE</strong>&nbsp;</p>
<p>The course is divided into four sections:</p>
<ul>
<li><strong style="font-family: inherit; font-size: 1rem;">Section 1</strong><span style="font-family: inherit; font-size: 1rem;"> provides an overview and introduces the course instructor and media experts</span></li>
<li><strong style="font-family: inherit; font-size: 1rem;">Section 2</strong><span style="font-family: inherit; font-size: 1rem;"> explains the use of different social media platforms as sources for newsgathering.</span></li>
<li><strong style="font-family: inherit; font-size: 1rem;">Section 3</strong><span style="font-family: inherit; font-size: 1rem;"> demonstrates how advanced search techniques in Google can be used for newsgathering.</span></li>
<li><strong style="font-family: inherit; font-size: 1rem;">Section 4</strong><span style="font-family: inherit; font-size: 1rem;"> is the course summary.</span></li>
</ul>
<p>&nbsp;</p>
<p><strong>HOW TO PASS:</strong></p>
<p>You will be presented with a practical exercise based on the concepts discussed which you will need to complete together with your feedback.</p>
<p>&nbsp;</p>
<p><strong>TIME COMMITMENT</strong></p>
<p>You can complete this course within 4 hours over multiple sessions.</p>"
预期产出:

This course carries&nbsp;4 hours of Continuing Professional Development (CPD) credits.&nbsp;
&nbsp;
In support of the Journalism Now Scholar Programme, for a limited time, there is no charge for the course certificate.&nbsp;&nbsp;
&nbsp;
COURSE OVERVIEW&nbsp;
This course will help give your use of social media a journalistic purpose.&nbsp; You'll learn how to find good stories, whether you're using Facebook, Twitter, Instagram, or any other form of social media. Once you've completed the course, you will be able to understand each of the social media platforms - they all have their own system which you will be able to get to grips with and you will discover how to refine your searches so that you get the information you need more easily.&nbsp; The course will help you become a good 'social listener' by giving you the best hashtags to use, as well as the best keywords.
&nbsp;
"The content is really good, I enjoyed it because I went in without knowing much but finished the course more knowledgeable. I learnt a lot of things." Pheladi from South Africa
&nbsp;
&nbsp;
WHAT YOU WILL LEARN
&bull; How to use SOCIAL MEDIA to FOLLOW breaking news and to FIND STORIES as well as sources.&nbsp;
&bull; How to use ADVANCED SEARCH TECHNIQUES as a tool for finding information and locating experts.
&bull; How to use social media to verify if a BREAKING NEWS story is true.
&bull; How to establish the ORIGIN OF PHOTOGRAPHS and how to verify them.
&nbsp;
MEET YOUR INSTRUCTORS
&nbsp;
SUE LLEWELLYN is your course instructor. For the past 10 years, Sue has worked as a trainer for thousands of journalists, teaching them how to use social media. Before that, she was a journalist for 15 years in the BBC Newsroom.&nbsp;
&emsp;
&nbsp;
Helping Sue is a team of experts (from left to right):

Matt Cooke works at the Google News Lab, Matt is an ex-BBC newsman who is a specialist in digital storytelling.&nbsp;
Anne-Marie Tomchak is the former presenter of BBC Trending who's now UK editor of Mashable.&nbsp;
Fred Mwasa is Deputy Editor-in-Chief at Kigali Today.&nbsp; Fred has a massive following on Twitter, with the highest number of followers for journalists in Rwanda.&nbsp;

&nbsp;
COURSE OUTLINE&nbsp;
The course is divided into four sections:

Section 1 provides an overview and introduces the course instructor and media experts
Section 2 explains the use of different social media platforms as sources for newsgathering.
Section 3 demonstrates how advanced search techniques in Google can be used for newsgathering.
Section 4 is the course summary.

&nbsp;
HOW TO PASS:
You will be presented with a practical exercise based on the concepts discussed which you will need to complete together with your feedback.
&nbsp;
TIME COMMITMENT
You can complete this course within 4 hours over multiple sessions."

使用此正则表达式解决此问题:


description.replace(/()|()|]+(>|$)/g'

那么您正在使用regExp寻求帮助?也许你应该加上标签。您所说的
Enter
是什么字符?是的regExp,Enter在这里表示\n。这通常称为新行。为什么不直接将
\n
添加到regExp中呢?已添加,但它不会生成预期的输出。除了regex还有别的方法吗?看看这个,这可能就是你想要的。
This course carries&nbsp;4 hours of Continuing Professional Development (CPD) credits.&nbsp;
&nbsp;
In support of the Journalism Now Scholar Programme, for a limited time, there is no charge for the course certificate.&nbsp;&nbsp;
&nbsp;
COURSE OVERVIEW&nbsp;
This course will help give your use of social media a journalistic purpose.&nbsp; You'll learn how to find good stories, whether you're using Facebook, Twitter, Instagram, or any other form of social media. Once you've completed the course, you will be able to understand each of the social media platforms - they all have their own system which you will be able to get to grips with and you will discover how to refine your searches so that you get the information you need more easily.&nbsp; The course will help you become a good 'social listener' by giving you the best hashtags to use, as well as the best keywords.
&nbsp;
"The content is really good, I enjoyed it because I went in without knowing much but finished the course more knowledgeable. I learnt a lot of things." Pheladi from South Africa
&nbsp;
&nbsp;
WHAT YOU WILL LEARN
&bull; How to use SOCIAL MEDIA to FOLLOW breaking news and to FIND STORIES as well as sources.&nbsp;
&bull; How to use ADVANCED SEARCH TECHNIQUES as a tool for finding information and locating experts.
&bull; How to use social media to verify if a BREAKING NEWS story is true.
&bull; How to establish the ORIGIN OF PHOTOGRAPHS and how to verify them.
&nbsp;
MEET YOUR INSTRUCTORS
&nbsp;
SUE LLEWELLYN is your course instructor. For the past 10 years, Sue has worked as a trainer for thousands of journalists, teaching them how to use social media. Before that, she was a journalist for 15 years in the BBC Newsroom.&nbsp;
&emsp;
&nbsp;
Helping Sue is a team of experts (from left to right):

Matt Cooke works at the Google News Lab, Matt is an ex-BBC newsman who is a specialist in digital storytelling.&nbsp;
Anne-Marie Tomchak is the former presenter of BBC Trending who's now UK editor of Mashable.&nbsp;
Fred Mwasa is Deputy Editor-in-Chief at Kigali Today.&nbsp; Fred has a massive following on Twitter, with the highest number of followers for journalists in Rwanda.&nbsp;

&nbsp;
COURSE OUTLINE&nbsp;
The course is divided into four sections:

Section 1 provides an overview and introduces the course instructor and media experts
Section 2 explains the use of different social media platforms as sources for newsgathering.
Section 3 demonstrates how advanced search techniques in Google can be used for newsgathering.
Section 4 is the course summary.

&nbsp;
HOW TO PASS:
You will be presented with a practical exercise based on the concepts discussed which you will need to complete together with your feedback.
&nbsp;
TIME COMMITMENT
You can complete this course within 4 hours over multiple sessions."