多行文本的 Vbscript 正则表达式?
Vbscript Regular expression for multiline text?
"value:=This customer has one or more active tax exemptions available\.
\n
\n
Do you want to apply a tax exemption to this transaction\?"
我试过像 "Value:=This.*"
这样的正则表达式,但它不能识别整个文本。请告诉我如何通过仅验证整个文本中的第一个单词来使用 VbScript 正则表达式识别整个文本。谢谢。
参见:How do I match any character across multiple lines in a regular expression?
例如:
Dim s : s = "value:=This customer has one or more active tax exemptions available." & vbCrLf & vbCrLf & "Do you want to apply a tax exemption to this transaction?"
With New RegExp
.Pattern = "^value:=This(.|\n|\r)*"
With .Execute(s)
WScript.Echo .Item(0).Value
End With
End With
...其 .Pattern
以 (^) 'value:=This' 开头,后跟任意字符 (.)、换行符(又名换行符) (\n),或回车 return (\r) 重复零次或多次 (*).
输出:
value:=This customer has one or more active tax exemptions available.
Do you want to apply a tax exemption to this transaction?
希望这对您有所帮助。
我猜,
value:=This\b[\s\S]*
可能工作正常。
Demo
如果您希望 simplify/modify/explore 表达式,regex101.com. If you'd like, you can also watch in this link 的右上面板已对其进行说明,它将如何匹配一些示例输入。
"value:=This customer has one or more active tax exemptions available\.
\n
\n
Do you want to apply a tax exemption to this transaction\?"
我试过像 "Value:=This.*"
这样的正则表达式,但它不能识别整个文本。请告诉我如何通过仅验证整个文本中的第一个单词来使用 VbScript 正则表达式识别整个文本。谢谢。
参见:How do I match any character across multiple lines in a regular expression?
例如:
Dim s : s = "value:=This customer has one or more active tax exemptions available." & vbCrLf & vbCrLf & "Do you want to apply a tax exemption to this transaction?"
With New RegExp
.Pattern = "^value:=This(.|\n|\r)*"
With .Execute(s)
WScript.Echo .Item(0).Value
End With
End With
...其 .Pattern
以 (^) 'value:=This' 开头,后跟任意字符 (.)、换行符(又名换行符) (\n),或回车 return (\r) 重复零次或多次 (*).
输出:
value:=This customer has one or more active tax exemptions available.
Do you want to apply a tax exemption to this transaction?
希望这对您有所帮助。
我猜,
value:=This\b[\s\S]*
可能工作正常。
Demo
如果您希望 simplify/modify/explore 表达式,regex101.com. If you'd like, you can also watch in this link 的右上面板已对其进行说明,它将如何匹配一些示例输入。