首页 > 解决方案 > 多行文本的Vbscript正则表达式?

问题描述

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

标签: regexvbscript

解决方案


请参阅:如何在正则表达式中匹配多行中的任何字符?

例如:

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) 或回车符 (\r) 重复零次或多次 (* )。

输出:

value:=This customer has one or more active tax exemptions available.

Do you want to apply a tax exemption to this transaction?

希望这可以帮助。


推荐阅读