マインドマップギャラリー 正規表現の基本
これは、正規表現の基本に関するマインド マップです。主な内容には、正規表現ツール、正規表現の応用例、正規表現の高度な機能、後方参照、グループ化とキャプチャ、数量指定子、アンカー、文字クラス、メタキャラクター、構成要素が含まれます。 、定義。
2024-11-19 08:56:01 に編集されましたThis template shows the structure and function of the reproductive system in the form of a mind map. It introduces the various components of the internal and external genitals, and sorts out the knowledge clearly to help you become familiar with the key points of knowledge.
This is a mind map about the interpretation and summary of the relationship field e-book, Main content: Overview of the essence interpretation and overview of the relationship field e-book. "Relationship field" refers to the complex interpersonal network in which an individual influences others through specific behaviors and attitudes.
This is a mind map about accounting books and accounting records. The main contents include: the focus of this chapter, reflecting the business results process of the enterprise, the loan and credit accounting method, and the original book of the person.
This template shows the structure and function of the reproductive system in the form of a mind map. It introduces the various components of the internal and external genitals, and sorts out the knowledge clearly to help you become familiar with the key points of knowledge.
This is a mind map about the interpretation and summary of the relationship field e-book, Main content: Overview of the essence interpretation and overview of the relationship field e-book. "Relationship field" refers to the complex interpersonal network in which an individual influences others through specific behaviors and attitudes.
This is a mind map about accounting books and accounting records. The main contents include: the focus of this chapter, reflecting the business results process of the enterprise, the loan and credit accounting method, and the original book of the person.
正規表現の基本
1. 意味
文字列内の文字の組み合わせを照合するために使用されるパターン
2. コンポーネント
通常の文字
自分と一致する
文字、数字、漢字など。
特殊文字
特別な意味を持つ文字
ピリオド (.)、アスタリスク (*) など。
3. メタキャラクター
正規表現の作成に使用される特殊文字
期間(。)
改行文字を除く任意の 1 文字と一致します
アスタリスク(*)
前の文字と 0 回以上一致します
プラス記号 ( )
前の文字と 1 回以上一致します
疑問符(?)
前の文字と 0 回または 1 回一致します
角括弧()
角括弧内の任意の 1 文字と一致します
ブレース ({})
一致する範囲を指定する
縦棒()
論理和を表します
バックスラッシュ(\\)
エスケープ文字、特殊文字の特別な意味を取り消す
4. 文字クラス
意味
指定された範囲内の任意の 1 文字と一致します
例
az
すべての小文字と一致する
09
すべての数字を一致させる
aAZ
すべての大文字と小文字に一致します
5. アンカーポイント
意味
特定の位置の文字列と一致する
タイプ
キャレット (^)
マッチングラインの開始位置
ドル記号 ($)
一致する行の終わり
6. 量指定子
意味
指定された文字または文字クラスの出現数
タイプ
貪欲な数量指定子
できるだけ多くの文字と一致します
のように*
前の文字と 0 回以上一致します
のように
前の文字と 1 回以上一致します
貪欲でない量指定子
できるだけ少ない文字と一致します
のように*?
貪欲に前の文字と 0 回以上一致します
のように ?
貪欲に前の文字と 1 回以上一致します
7. グループ化とキャプチャ
意味
正規表現の一部を結合する
効果
一致する部分文字列を抽出する
組み合わせ全体に量指定子を適用する
文法
括弧(())
グループの作成
(a(bc)) など
「ab」または「ac」と一致します
8. 後方参照
意味
以前に定義されたグループへの参照
文法
バックスラッシュと数字
例:\1
最初のグループへの参照
9. 正規表現の高度な機能
ゼロ幅アサーション
文字ではなく位置を一致させる
楽しみにしています(?=)
特定の位置以降のコンテンツを一致させる
後ろ向き(?<=)
特定の位置より前のコンテンツと一致する
否定的な先読み(?!)
特定の位置以降の条件に当てはまらないコンテンツを一致させる
ネガティブで後ろ向き(?<!)
条件を満たさない特定の位置より前のコンテンツを照合する
条件式
条件に基づいて異なる文字列を照合する
(a(bc)d) など
「ab」、「ac」、または「d」に一致します
モード修飾子
正規表現の動作を変更する
私のように
大文字と小文字を無視する
mなど
複数行モード
など
ドット (.) を改行を含む任意の文字と一致させる
あなたのような
Unicode 文字セットを使用した照合
×など
正規表現にスペースやコメントを追加できるようにする
10. 正規表現の適用例
テキスト検索
テキスト内のパターンに一致する文字列を検索する
データの検証
入力データ形式が正しいことを確認します
テキストの置換
パターンに一致するテキスト内の文字列を置換します
文字列の分割
パターンに基づいて文字列を配列に分割する
プログラミング言語でのアプリケーション
ほとんどのプログラミング言語は文字列処理の正規表現をサポートしています
Python、Java、JavaScript など。
11. 正規表現ツール
オンライン正規表現テスター
正規表現のテストとデバッグ用
統合開発環境 (IDE) のサポート
正規表現の検索および置換機能を提供します
テキストエディタプラグイン
テキストエディタの正規表現処理機能を強化する
コマンドラインツール
grep、sed など。
コマンドラインからテキストデータを処理する場合