如何从字符串中删除span标签? [英] how to remove span tag from the string?

查看:169
本文介绍了如何从字符串中删除span标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从字符串中删除span标记。它是否可行。?

I need to remove the span tag from string .Is it posible .?

我的输入是

In open <span class="">court</span> at 11:01 a.m.)
          THE <span class="">COURT</span>:  Our interpreter.
(NOTE:  Spanish interpreter Rosa Lopez-Gaston sworn.)
          SPEAKER 2:  Judy Faviell for the State.  
          SPEAKER 1:  Carey Bhalla for Mr. Garcia, who is present in custody, Your Honor.  
          SPEAKER 2:  Judge, we do have a change of plea, which I will tender to the <span class="">Court</span>.  
          THE <span class="">COURT</span>:

输出是

 In open court at 11:01 a.m.)
              THE COURT:  Our interpreter.
    (NOTE:  Spanish interpreter Rosa Lopez-Gaston sworn.)
              SPEAKER 2:  Judy Faviell for the State.  
              SPEAKER 1:  Carey Bhalla for Mr. Garcia, who is present in custody, Your Honor.  
              SPEAKER 2:  Judge, we do have a change of plea, which I will tender to the <span class="">Court</span>.  
              THE COURT:


推荐答案

针对您编辑过的问题你可以这样做:

For your edited question you can do this:

var str = // your string here

str = str.replace(/<\/?span[^>]*>/g,"");

演示: http: //jsfiddle.net/vXXJ6/

这篇关于如何从字符串中删除span标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆