仅查找数字模式的 VBScript 正则表达式 [英] VBScript Regular Expressions to find pattern of numbers only
本文介绍了仅查找数字模式的 VBScript 正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道如何使用 vbscript 正则表达式来查找文本中包含 5 个数字的任何部分.
I need to know how to use vbscript regular expressions to find any part of the text that has 5 numbers together.
例如:
NumberNumberNumberNumberNumber
NumberNumberNumberNumberNumber
或
12345
推荐答案
使用模式\d{5}"指定五位数字..Execute 的匹配集合将包含您感兴趣的部分.在代码中:
Use the pattern "\d{5}" to specify five digits. The match collection from .Execute will hold your interesting parts. In code:
>> Set r = New RegExp
>> r.Global = True
>> r.Pattern = "\d{5}"
>> s = "12345a1234b1234554321c123456d"
>> For Each m In r.Execute(s)
>> WScript.Echo m.Value
>> Next
>>
12345
12345
54321
12345
这篇关于仅查找数字模式的 VBScript 正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文