2011-09-01から1ヶ月間の記事一覧

VBScript のプロパティ、Pattern プロパティ {n,m}

Set r = New RegExp str = "foo" r.Pattern = "o{0,1}" Set Matches = r.Execute(str) MsgBox Matches(0) ' str = "foo" r.Pattern = "o{1,3}" Set Matches = r.Execute(str) MsgBox Matches(0) ' oo

VBScript のプロパティ、Pattern プロパティ {n,}

Set r = New RegExp str = "foo" r.Pattern = "o{0,}" Set Matches = r.Execute(str) MsgBox Matches(0) ' str = "foo" r.Pattern = "o{1,}" Set Matches = r.Execute(str) MsgBox Matches(0) ' oo str = "foo" r.Pattern = "o{3,}" Set Matches = r.Execute…

VBScript のプロパティ、Pattern プロパティ {n}

Set r = New RegExp str = "abc" r.Pattern = "b{0}" Set Matches = r.Execute(str) MsgBox Matches(0) ' str = "foo" r.Pattern = "o{1}" Set Matches = r.Execute(str) MsgBox Matches(0) ' o

VBScript のプロパティ、Pattern プロパティ x|y

Set r = New RegExp str = "abc" r.Pattern = "a|bbc" Set Matches = r.Execute(str) MsgBox Matches(0) ' a r.Pattern = "(a|b)bc" Set Matches = r.Execute(str) MsgBox Matches(0) ' abc r.Pattern = "(abc|b)" Set Matches = r.Execute(str) MsgBox Matc…

VBScript のプロパティ、Pattern プロパティ (pattern)

Set r = New RegExp str = "abc" r.Pattern = "a(.+)" Set Matches = r.Execute(str) MsgBox Matches(0) ' abc MsgBox Matches(0).SubMatches(0) ' bc str = "abcABC" r.Pattern = "a(b)(c)" r.Global = True r.IgnoreCase = True Set Matches = r.Execute(s…

VBScript のプロパティ、Pattern プロパティ .

Set r = New RegExp str = "abc" r.Pattern = "a.c" Set Matches = r.Execute(str) MsgBox Matches(0) ' abc str = "abc" & vbCRLF & "abc" r.Pattern = ".a" Set Matches = r.Execute(str) MsgBox Matches.Count ' 0

VBScript のプロパティ、Pattern プロパティ ?

Set r = New RegExp str = "abc" r.Pattern = "ab?" Set Matches = r.Execute(str) MsgBox Matches(0) ' ab str = "abc" r.Pattern = "ac?" Set Matches = r.Execute(str) MsgBox Matches(0) ' a str = "abbbc" r.Pattern = "ab?" Set Matches = r.Execute(s…

VBScript のプロパティ、Pattern プロパティ +

Set r = New RegExp str = "abc" r.Pattern = "ab+" Set Matches = r.Execute(str) MsgBox Matches(0) ' ab str = "abbbc" r.Pattern = "ab+" Set Matches = r.Execute(str) MsgBox Matches(0) ' abbb

VBScript のプロパティ、Pattern プロパティ *

Set r = New RegExp str = "abc" r.Pattern = "ac*b" Set Matches = r.Execute(str) MsgBox Matches.Count ' 1 MsgBox Matches(0) ' ab str = "abc" r.Pattern = "acb" Set Matches = r.Execute(str) MsgBox Matches.Count ' 0

VBScript のプロパティ、Pattern プロパティ $

Set r = New RegExp str = "abc" r.Pattern = "b" Set Matches = r.Execute(str) MsgBox Matches.Count ' 1 MsgBox Matches(0) ' b str = "abc" r.Pattern = "b$" Set Matches = r.Execute(str) MsgBox Matches.Count ' 0

VBScript のプロパティ、Pattern プロパティ ^

Set r = New RegExp str = "abc" r.Pattern = "b" Set Matches = r.Execute(str) MsgBox Matches(0) ' b str = "abc" r.Pattern = "^b" Set Matches = r.Execute(str) MsgBox Matches.Count ' 0

VBScript のプロパティ、Pattern プロパティ \

Set r = New RegExp str = "abc" & vbCRLF & "abc" r.Pattern = "\na" Set Matches = r.Execute(str) MsgBox Matches(0).FirstIndex ' 4 str = "abc\abc" r.Pattern = "\\a" Set Matches = r.Execute(str) MsgBox Matches(0).FirstIndex ' 3 str = "a(b)c" r…

VBScript のプロパティ、Number プロパティ

まんま On Error Resume Next Err.Raise vbObjectError + 1, "SomeObject" ' エラー番号 1 を発生させます。 MsgBox ("エラー番号 " & CStr(Err.Number) & " " & Err.Description) Err.Clear ' エラーのクリア。

VBScript のプロパティ、Length プロパティ

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のプロパティ、IgnoreCase プロパティ

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のプロパティ、HelpContext, HelpFile プロパティ

ほぼ、まんま ヘルプの表示はできない 「" のトピックを参照してください。」の箇所、終端されていなかった On Error Resume Next Dim Msg Err.Clear Err.Raise 6 ' オーバーフロー エラーを発生させます。 Err.Helpfile = "C:\WINDOWS\Help\windows.chm" Er…

VBScript のプロパティ、Global プロパティ

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のプロパティ、FirstIndex プロパティ

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のプロパティ、Description プロパティ

まんま On Error Resume Next Err.Raise 6 ' オーバーフロー エラーを発生させます。 MsgBox ("エラー番号 " & CStr(Err.Number) & " " & Err.Description) Err.Clear ' エラーのクリア。

VBScript の演算子、演算子の優先順位

MsgBox 1 + 1 & 2 + 3 ' 25 MsgBox 10 = 1 & 0 ' True MsgBox 10 = (1 & 0) ' True MsgBox (10 = 1) & 0 ' False0 MsgBox Not 1 = 1 ' False MsgBox Not (1 = 1) ' False

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.E…

VBScript のオブジェクトとコレクション、RegExp オブジェクト

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のオブジェクトとコレクション、Matches コレクション

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のオブジェクトとコレクション、Match オブジェクト

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のオブジェクトとコレクション、Err オブジェクト

まんま On Error Resume Next Err.Raise 6 ' オーバーフロー エラーを発生させます。 MsgBox ("エラー番号 " & CStr(Err.Number) & " " & Err.Description) Err.Clear ' エラーのクリア。

VBScript のオブジェクトとコレクション、Class オブジェクト

説明がさっぱり分からない。 Class Foo End Class Set x = New Foo

VBScript のメソッド、Test

まんま Function RegExpTest(patrn, strng) Dim regEx, retVal ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = False ' 大文字と小文字を区別するように設定し…

VBScript のメソッド、Replace

まんま Function ReplaceTest(patrn, replStr) Dim regEx, str1 ' 変数を作成します。 str1 = "The quick brown fox jumped over the lazy dog." Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.Ig…

VBScript のメソッド、Execute

まんま Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 変数を作成します。 Set regEx = New RegExp ' 正規表現を作成します。 regEx.Pattern = patrn ' パターンを設定します。 regEx.IgnoreCase = True ' 大文字と小文字を区別しないよう…

VBScript のメソッド、Clear

まんま On Error Resume Next Err.Raise 6 ' オーバーフロー エラーを発生させます。 MsgBox ("エラー番号 " & CStr(Err.Number) & " " & Err.Description) Err.Clear ' エラーのクリア。