asp正则字符替换

snlixing 2020-04-03 11:00:01
<span>hello,world</span>

怎么用正则把所有<span></span>替换成<input type='text'><input type=hidden value='hello,world'>
...全文
187 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dogfish 2020-04-05
  • 打赏
  • 举报
回复
s = "<span  style='font-size:4px'>asfsfsdfs</span>"
Dim RegEx, RegMatches
Set RegEx = New RegExp
RegEx.Pattern = "<span([^>]+?)>([^<]+?)<\/span>"
RegEx.Global = True
Set RegMatches = RegEx.Execute(s)
For Each RegMatch In RegMatches
  Response.Write RegMatch.SubMatches(1)
Next
snlixing 2020-04-04
  • 打赏
  • 举报
回复
引用 1 楼 qq_63572063 的回复:

str = "<span>hello,world</span><span>hello,world_2</span><span>hello,world_3</span>"
Set RegEx = New RegExp
RegEx.Global = True
RegEx.IgnoreCase = True
RegEx.Pattern = "<span>([^<]+?)<\/span>"'"[a-z](\d+)[a-z]{3}"
str = regex.Replace(str,"<input type=hidden value='$1'>")
Set RegEx = Nothing
Response.Write str


谢谢,现在有这些数据,AA,BB,CC

怎么将这些数据按", "分割后匹配到Input里面呢

str = regex.Replace(str,"<input type=hidden value='AA'>")
str = regex.Replace(str,"<input type=hidden value='BB'>")

像这样的
snlixing 2020-04-04
  • 打赏
  • 举报
回复
比如<span style='font-size:4px'>asfsfsdfs</span> 怎么去掉<span>和</span>呢,只留下asfsfsdfs文字
  • 打赏
  • 举报
回复

str = "<span>hello,world</span><span>hello,world_2</span><span>hello,world_3</span>"
Set RegEx = New RegExp
RegEx.Global = True
RegEx.IgnoreCase = True
RegEx.Pattern = "<span>([^<]+?)<\/span>"'"[a-z](\d+)[a-z]{3}"
str = regex.Replace(str,"<input type=hidden value='$1'>")
Set RegEx = Nothing
Response.Write str

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧