[問題] VBA的regex
看板RegExp (正規表示式 Regular Expression)作者gecer (gecer)時間11年前 (2014/07/05 08:53)推噓2(2推 0噓 2→)留言4則, 2人參與討論串1/1
語言 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://www.ptt.cc/bbs/RegExp/M.1404521632.A.DE0.html
推
07/05 19:54, , 1F
07/05 19:54, 1F
推
07/07 09:22, , 2F
07/07 09:22, 2F
→
07/07 09:22, , 3F
07/07 09:22, 3F
→
07/07 09:23, , 4F
07/07 09:23, 4F
RegExp 近期熱門文章
PTT數位生活區 即時熱門文章