看板Programming
标 题Re: 请问这是VB 6.0的语法吗?
发信站不良牛牧场 (Mon Nov 13 22:58:13 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.au!zoonews.ee.ntu!SimFar
It's VB.NET....
not VB6
※ 引述《[email protected] (延宕的人生)》之铭言:
: 请问各位先进
: 我想要用VB来写有关Regular Expression的处理
: 结果找到如下程式码:
: 看起来满像是VB的,但是放在VB6.0当中,第一行Dim就红字了
: 其中Dim r As Regex = new Regex(pat, RegexOptions.IgnoreCase)
: 也有问题,所以想请问我找到的语法是for VB的吗?
: 另外,能否提供一下VB关於Regular Expression的范例
: Dim text As String = "One car red car blue car"
: Dim pat As String = "(\w+)\s+(car)"
: ' Compile the regular expression.
: Dim r As Regex = new Regex(pat, RegexOptions.IgnoreCase)
: ' Match the regular expression pattern against a text string.
: Dim m As Match = r.Match(text)
: Dim matchcount as Integer = 0
: 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 j
: Next i
: m = m.NextMatch()
: End While
--
╭──── Origin:
<不良牛牧场> bbs.badcow.com.tw (210.200.247.200)─────╮
│ ↘ Welcome to SimFarm BBS -- From : [59.112.103.184] │
╰◣◣◢ ◢◢《不良牛免费拨接→电话:40586000→帐号:zoo→密码:zoo》 ◣◣◢ ─╯