我正在尝试运行这个正则表达式[\ s] +(<)|(>)[\ s] +
dim myRegExp as object
Set myRegExp = New RegExp
myRegExp.MultiLine = True
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "[\s]+(<)|(>)[\s]+"
'myRegExp.Test (str)
str = myRegExp.Replace(str, "$2$1")
这似乎不起作用
您可以在http://www.regextester.com/上测试运行该正则表达式 它完美地运作
假设从HTML标签的左侧和右侧删除空格以优化网页,而不删除html标记之间的实际文本中的空格。
<br> adsfdf </br> <img
asdddasd >
sdfdsf <br> <yah>43 3453490
90 <tag>
<tag>
变成
<br>adsfdf</br><img asdddasd>sdfdsf<br><yah>43 3453490 90<tag><tag>
为什么它在VB6 / VBScript中不起作用?感谢
答案 0 :(得分:0)
请改为尝试:
myRegExp.Pattern = "\s+(<)|(>)\s+"
str = myRegExp.Replace(str, "$2$1")
VB6 / VBScript正则表达式可能不喜欢字符类中的\s
。