作者gecer (gecer)
看板RegExp
標題[問題] VBA的regex
時間Sat Jul 5 08:53:49 2014
語言 VBA excel 2007 windows XP
code as follow
********************************************************************
Dim myRegExp As Object
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "^(\d+\s+[0-7]\s+\d+(uA|mV))"
Dim s As String: s = "6532 0 70mV "
Dim m As Object
Set m = myRegExp.Execute(s)
**********************************************************************
I want to match "6532 0 70mV" or "6532 0 70uA"
but when s is "6532 0 70uA" the m contains only one item,which is
"6532 0 70uA"
http://i.imgur.com/PFQNfZ9.png ,but when
s="6532 0 70mV" it contains 2 items "6532 0 70mV" and "mV"
http://i.imgur.com/Pg2gqNu.png,
I don't know why the later case contains 2
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.255.1.224
※ 文章網址: http://webptt.com/m.aspx?n=bbs/RegExp/M.1404521632.A.DE0.html
1F:推 LPH66:((uA)|(mV)) 這樣試試? 07/05 19:54
2F:推 lin1987www:你累了 Q_Q 仔細看其實是你看錯了! Match的數量都是1 07/07 09:22
3F:→ lin1987www:第一張圖是你看Match(m)的數量,第二張圖是你Pattern 07/07 09:22
4F:→ lin1987www:Match的數量 07/07 09:23