Vbscript多行文本的正则表达式? Demo

"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正则表达式识别整个文本。谢谢。

hushikai123 回答:Vbscript多行文本的正则表达式? Demo

请参阅: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 ',后跟任意字符(。),换行符(aka,newline)(\ n) ,或回车(\ 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


如果您希望简化/修改/探索表达式,请在regex101.com的右上角进行说明。如果愿意,您还可以在this link中查看它如何与某些示例输入匹配。


本文链接:https://www.f2er.com/3135395.html

大家都在问