[問題] VBA 2010的regular expression如何非貪婪
看板RegExp (正規表示式 Regular Expression)作者gecer (gecer)時間10年前 (2014/11/12 22:58)推噓1(1推 0噓 5→)留言6則, 2人參與討論串1/1
/* 聽說註明使用的語言、環境
* 問題有可能較容易被解決...
*/
excel 2010 win7
code is as below
Option Explicit
Sub t()
Dim reg As Object
Dim s As String
Dim match As Object
Set reg = CreateObject("VBScript.RegExp")
reg.Pattern = "(123.*?abc)"
reg.ignoreCase = True
reg.MultiLine = False
reg.Global = True
s = "dfr123 123 1235abc"
Set match = reg.Execute(s)
End Sub
and the result is
http://i.imgur.com/VZda4lY.png
小弟想要抓到最短的1235abc 字串 請問要如何更正?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.255.27.116
※ 文章網址: http://www.ptt.cc/bbs/RegExp/M.1415804330.A.9D3.html
推
11/12 23:33, , 1F
11/12 23:33, 1F
→
11/12 23:34, , 2F
11/12 23:34, 2F
→
11/12 23:34, , 3F
11/12 23:34, 3F
→
11/25 04:48, , 4F
11/25 04:48, 4F
→
11/25 04:50, , 5F
11/25 04:50, 5F
→
11/25 04:50, , 6F
11/25 04:50, 6F
RegExp 近期熱門文章
PTT數位生活區 即時熱門文章