[問題] VBA的regex

看板RegExp (正規表示式 Regular Expression)作者 (gecer)時間11年前 (2014/07/05 08:53), 編輯推噓2(202)
留言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
((uA)|(mV)) 這樣試試?
07/05 19:54, 1F

07/07 09:22, , 2F
你累了 Q_Q 仔細看其實是你看錯了! Match的數量都是1
07/07 09:22, 2F

07/07 09:22, , 3F
第一張圖是你看Match(m)的數量,第二張圖是你Pattern
07/07 09:22, 3F

07/07 09:23, , 4F
Match的數量
07/07 09:23, 4F
文章代碼(AID): #1JjqoWtW (RegExp)
文章代碼(AID): #1JjqoWtW (RegExp)