如果文本字符串中包含的某些词,包装这些字词span标记 [英] If text string contains certain words, wrap those words in a span tag

查看:211
本文介绍了如果文本字符串中包含的某些词,包装这些字词span标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找这里一点帮助。我有一个文本字符串,如:

Looking for a little help here. I have a text string like:

> ...And The World Laughs With You (feat Thom Yorke)

使用的VBScript ,如果文本字符串具有(技艺在里面,我想整个包住在span标记方括号的文字。结果
所以,上面的例子看起来像:

With vbscript, if the text string has "(feat " in it, I want to wrap the whole bracketed text in a span tag.
So, the example above would look like:

> ...And The World Laughs With You <span>(feat Thom Yorke)</span>

希望这是有道理的,并预先感谢您的帮助!

Hope this makes sense and thank you in advance for the help!

干杯,结果
德鲁

Cheers,
Drew

推荐答案

尝试用这个逻辑。

     dim str 
   str = "And The World Laughs With You (feat Thom Yorke)"

   If  INSTR(str,"(feat ") > -1 Then
        str = REPLACE(str,"(feat ","<span>(feat ") 
        str = REPLACE(str,")",")</span>") 
   End If

   Response.Write("Result:- "  + str)  

这篇关于如果文本字符串中包含的某些词,包装这些字词span标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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