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

progress indicator
他の提案はありません。
クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
Visual Studio 2010
Visual Studio
Visual Studio の言語
JScript
正規表現の概説
 正規表現の使用方法
すべて縮小/すべて展開 すべて縮小
コンテンツの表示:   英語と日本語を並べて表示コンテンツの表示: 英語と日本語を並べて表示
JScript 10.0
Uses for Regular Expressions

A typical search and replace operation requires you to provide the exact text that matches the intended search result. Although this technique may be adequate for simple search and replace tasks in static text, it lacks flexibility and makes searching dynamic text at least difficult if not impossible.

With regular expressions, you can:

  • Test for a pattern within a string.

    For example, you can test an input string to see if a telephone number pattern or a credit card number pattern occurs within the string. This is called data validation.

  • Replace text.

    You can use a regular expression to identify specific text in a document and either remove it completely or replace it with other text.

  • Extract a substring from a string based upon a pattern match.

    You can find specific text within a document or input field.

For example, you may need to search an entire Web site, remove outdated material, and replace some HTML formatting tags. In this case, you can use a regular expression to determine if the material or the HTML formatting tags appears in each file. This process reduces the affected files list to those that contain material targeted for removal or change. You can then use a regular expression to remove the outdated material. Finally, you can use a regular expression to search for and replace the tags.

A regular expression is also useful in a language, such as JScript or C that is not known for its string-handling ability.

JScript 10.0
正規表現の使用方法

一般的な検索および置換操作では、検索するテキストを正確に指定する必要があります。 静的テキストを対象とする単純検索や置換作業にはこの方法で十分ですが、動的テキストでは柔軟性に欠け、少なくとも検索は困難になります。

正規表現を使用すると、次のことができます。

  • 文字列内のパターンのテスト。

    たとえば、入力文字列をテストして、文字列内に電話番号またはクレジットカード番号のパターンがあるかどうかをチェックできます。 これをデータ確認と呼びます。

  • 文字列の置換。

    正規表現を使用して、ドキュメント内にある文字列を特定し、削除したり、他の文字列と置換したりできます。

  • パターン一致に基づく、文字列からの部分文字列の抽出。

    ドキュメントまたは入力フィールド内の特定の文字列を検索できます。

たとえば、Web サイト全体を検索して、古い内容を削除したり、HTML タグを置換したりする必要がある場合について考えてみます。 この場合、正規表現を使用して、各ファイルに削除対象の内容や置換対象の HTML タグがあるかどうかを確認できます。 この処理により、削除や変更の対象となる内容を含むファイルを絞り込みます。 続いて、正規表現を使用して古い内容を削除できます。 さらに、正規表現を使用して、タグを検索して置換できます。

正規表現は、JScript や C などの言語や、文字列処理の機能がわからない言語でも役に立ちます。

その他の技術情報

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