【问题标题】:Vbscript Regular expression for multiline text?多行文本的Vbscript正则表达式?
【发布时间】:2019-11-08 19:52:10
【问题描述】:
"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 正则表达式识别整个文本。谢谢。

【问题讨论】:

标签: regex vbscript


【解决方案1】:

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

输出:

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

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

希望这会有所帮助。

【讨论】:

【解决方案2】:

我猜,

value:=This\b[\s\S]*

可能工作正常。

Demo


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


【讨论】:

  • 谢谢!!这正是我正在寻找的。​​span>
猜你喜欢
  • 1970-01-01
  • 2011-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多