首页 > 编程 > Regex > 正文

用正则取出html页面中script段落里的内容

2020-03-16 21:22:05
字体:
来源:转载
供稿:网友
这个功能对于字符串中的段落分解比较有用
  1. <body>  
  2. </body>  
  3. </html>  
  4. <script>  
  5. descript="第一段script"  
  6. </script>  
  7. <script>  
  8. descript="第二段script"  
  9. str=document.body.innerHTML  
  10. a=str.match(//<script((.|/n)*?)/<//script/>/gi)  
  11. alert(a[0])  
  12. alert(a[1])  
  13. </script>  

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表