VBScript のオブジェクトとコレクション、SubMatches コレクション
まんま
Function SubMatchTest(inpStr) Dim oRe, oMatch, oMatches Set oRe = New RegExp ' e-mail アドレスを検索します (正確な RegExp ではありません)。 oRe.Pattern = "(\w+)@(\w+)\.(\w+)" ' Matches コレクションを取得します。 Set oMatches = oRe.Execute(inpStr) ' Matches コレクションの最初の項目を取得します。 Set oMatch = oMatches(0) ' 結果の文字列を作成します。 ' Match オブジェクトは、dragon@xyzzy.com 全体に一致します。 retStr = "Email アドレス : " & oMatch & vbNewline ' アドレスのサブマッチの部分を取得します。 retStr = retStr & "Email のエイリアス : " & oMatch.SubMatches(0) ' dragon retStr = retStr & vbNewline retStr = retStr & "組織 : " & oMatch.SubMatches(1) ' xyzzy SubMatchTest = retStr End Function MsgBox(SubMatchTest("dragon@xyzzy.com.にメールを送信してください。ありがとうございました。"))
「retStr = retStr & "組織 : " " & oMatch. SubMatches(1)' xyzzy」の行間違いあった