==[[Excel VBA 正規表現を使う]]==[[Excel VBA]] | {{category [[Category:正規表現}}{{category VBAソース片}}]]
[[http://msdn.microsoft.com/library/ja/default.asp?url=/library/ja/script56/html/vsobjRegExp.asp MSDN Visual Basic Scripting Edition RegExp オブジェクト]] |
===基本的な使い方===
Dim value As String '解析する文字列
Set reg = CreateObject("[[VBScript]].RegExp")
reg.Pattern = "^[ ]+([0-9A-Z@]+).*[ ]FOUND[ ].*"
'reg.Global = True '/g オプションを指定する
i = 0
ReDim [[R]]eDim indexes(i)
Set reg = CreateObject("[[VBScript]].RegExp")
reg.Pattern = "([0-9]{1,3})"
reg.Global = True
' 一致情報のコレクション
For Each match In matches
ReDim [[R]]eDim Preserve indexes(i)
indexes(i) = match.SubMatches(0)
i = i + 1
Next
End If