vba 正则 提取 html,VBA正则表达式提取托架之间的文本,没有括号

尝试这个:

\[(x)\]|\[(\d*)\]你不想被捕获的东西,不要把它们放在里面()。这用于分组

Explanation

You will get x and 33 in $1 and $2Dot Net Sample

好吧,我为你做好了准备,虽然远离vb很长时间。可能不需要很多,但它可以帮助您更好地理解它

Imports System.Text.RegularExpressions

Module Example

Public Sub Main()

Dim text As String = "[x] Alpha [33] Beta]"

Dim pattern As String = "\[(x)\]|\[(\d*)\]"

' Instantiate the regular expression object.

Dim r As Regex = new Regex(pattern, RegexOptions.IgnoreCase)

' Match the regular expression pattern against a text string.

Dim m As Match = r.Match(text)

Dim matchcount as Integer = 0

Do While m.Success

matchCount += 1

Console.WriteLine("Match" & (matchCount))

Dim i As Integer

For i = 1 to 2

Dim g as Group = m.Groups(i)

Console.WriteLine("Group" & i & "='" & g.ToString() & "'")

Dim cc As CaptureCollection = g.Captures

Dim j As Integer

For j = 0 to cc.Count - 1

Dim c As Capture = cc(j)

Console.WriteLine("Capture" & j & "='" & c.ToString() _

& "', Position=" & c.Index)

Next

Next

m = m.NextMatch()

Loop

End Sub

End Module

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值