翻訳への提案を行います
 
他のユーザーによる提案:

progress indicator
他の提案はありません。
クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
Visual Studio 2010
Visual Studio
Visual Studio の言語
JScript
JScript リファレンス
言語リファレンス
RegExp オブジェクト
すべて縮小/すべて展開 すべて縮小
コンテンツの表示:   英語と日本語を並べて表示コンテンツの表示: 英語と日本語を並べて表示
JScript 10.0
RegExp Object

An intrinsic global object that stores information about the results of regular expression pattern matches. This object cannot be constructed explicitly.

The RegExp object has no methods.

The RegExp object cannot be created directly, but it is always available. Until a successful regular expression search has been completed, the initial values of the various properties of the RegExp object are as follows:

Property

Shorthand

Initial Value

index

 

-1

input

$_

Empty string

lastIndex

 

-1

lastMatch

$&

Empty string.

lastParen

$+

Empty string.

leftContext

$`

Empty string.

rightContext

$'

Empty string.

$1 - $9

 

Empty string.

The global RegExp object should not be confused with the Regular Expression object. Although they sound similar, they are separate and distinct. The properties of the global RegExp object contain continually updated information about each match as it occurs, while the properties of the Regular Expression object contain only information about the matches that occur with a single instance of the Regular Expression.

NoteNote

The properties of RegExp are not available when running in fast mode, the default for JScript. To compile a program from the command line that uses these properties, you must turn off the fast option by using /fast-. It is not safe to turn off the fast option in ASP.NET because of threading issues.

The following example illustrates the use of the global RegExp object. This example must be compiled with the /fast- option.

var re : RegExp = new RegExp("d(b+)(d)","ig");
var arr : Array = re.exec("cdbBdbsbdbdz");
print("$1 contains: " + RegExp.$1);
print("$2 contains: " + RegExp.$2);
print("$3 contains: " + RegExp.$3);

The output from this code is:

$1 contains: bB
$2 contains: d
$3 contains:
JScript 10.0
RegExp オブジェクト

正規表現パターン一致の結果についての情報を保存する組み込みのグローバルなオブジェクトです。 このオブジェクトを明示的に構築することはできません。

RegExp オブジェクトには、メソッドはありません。

RegExp オブジェクトは、直接作成することはできませんが、いつでも使用できます。 次の表は、正規表現の検索が成功するまでの、RegExp オブジェクトのさまざまなプロパティの初期値を示したものです。

プロパティ

略式

[初期の値]

index

 

-1

input

$_

空の文字列

lastIndex

 

-1

lastMatch

$&

空の文字列

lastParen

$+

空の文字列

leftContext

$`

空の文字列

rightContext

$'

空の文字列

$1 - $9

 

空の文字列

グローバルな RegExp オブジェクトを Regular Expression オブジェクトと混同しないようにしてください。 名前は似ていますが、これらの 2 つのオブジェクトには明確な違いがあります。 グローバルな RegExp オブジェクトのプロパティには、一致が検出されるたびに更新される情報が格納されるのに対し、Regular Expression オブジェクトのプロパティには、Regular Expression の 1 つのインスタンスによる一致に関する情報だけが格納されます。

メモメモ

RegExp のプロパティは、高速モードで実行されている場合は利用できません。JScript の既定のモードは高速モードです。 これらのプロパティを使用するプログラムをコマンド ラインからコンパイルするには、/fast- を使用して fast オプションをオフにする必要があります。 ASP.NET で fast オプションをオフにするのは安全ではありません。スレッドに関する問題が発生する場合があります。

次のコードは、グローバルな RegExp オブジェクトの使用例です。 この例は、/fast- オプションを使用してコンパイルする必要があります。

var re : RegExp = new RegExp("d(b+)(d)","ig");
var arr : Array = re.exec("cdbBdbsbdbdz");
print("$1 contains: " + RegExp.$1);
print("$2 contains: " + RegExp.$2);
print("$3 contains: " + RegExp.$3);

このコードの出力は次のようになります。

$1 contains: bB
$2 contains: d
$3 contains:
コミュニティ コンテンツ   コミュニティ コンテンツとは
新しいコンテンツの追加 RSS  注釈
Processing
© 2012 Microsoft. All rights reserved. 使用条件 | 商標 | プライバシー
Page view tracker