Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

書籍 Regular Expressions Cookbook

概要

Oreillyの英書「Regular Expressions Cookbook」の学習まとめ。
自分の中で既知の情報は除外してまとめるため書籍全般をカバーするわけではない。
正規表現の動作確認はRubyで行います。

各章

Chapter 1. Introduction to Regular Expressions

とくになし

Chapter 2. Basic Regular Expression Skills
項目 内容
(?i)ascii ignore case。大文字小文字を無視してマッチングする
Nonprinting characters table 非表示文字の表現方法一覧
Word Boundary 境界、非境界
Group and Capture Parts of the Match 複数用語を1つのグループとしてマッチさせる方法
Match Previously Matched Text Again 前回一致した内容を再びマッチさせる方法について
Capture and Name Parts of the Match 名前付きキャプチャについて
Eliminate Needless Backtracking 独占的量指定子について
Add Comments to a Regular Expression 正規表現のコメントについて
Insert the Regex Match into the Replacement Text マッチした内容全体の取得について
Insert Part of the Regex Match into the Replacement Text マッチ内容をグループのindexを指定して取得
Chapter 3. Programming with Regular Expressions
項目 内容
Retrieve a List of All Matches マッチした内容全体をリストで取得
Find a Match Within Another Match マッチした内容を、更に別の条件にマッチさせる
Replace All Matches Within the Matches of Another Regex 正規表現で抽出した内容のうち、更に別の正規表現に一致するもののみ置換
get left or right or match String 正規表現のマッチング結果の取得
get start or end index 正規表現のマッチング結果の位置情報の取得
Search Line by Line コマンドラインのように、各行に対して正規表現を行う方法について

Chapter 4. Validation and Formatting

項目 内容
Validate Handy Phone Number 携帯電話番号のバリデーション
Validate Traditional Date Formats 日付のバリデーション
Validate Traditional Time Formats 時間のバリデーション
Limit Input to Alphanumeric Characters 半角英数字のバリデーション
Limit the Length of Text 文字数のバリデーション
Limit the Number of Lines in Text 行数のバリデーション
Reformat Names From “FirstName LastName” to “LastName FirstName” 姓名の入れ替えについて

Chapter 5. Words, Lines, and Special Characters

項目 内容
Find a Specific Word 単語のマッチングについて
Find Similar Words 似た単語のマッチングについて
Find All Except a Specific Word 特定の単語を除く単語のマッチングについて
Find Repeated Words 単語の繰り返しのマッチングについて
Remove Duplicate Lines 重複行の削除について
Match Complete Lines That Contain a Word ある単語を含む行について
Match Complete Lines That Do Not Contain a Word ある単語を含む行について
Escape Regular Expression Metacharacters 正規表現のエスケープについて

Chapter 6. Numbers

とくになし

Chapter 7. URLs, Paths, and Internet Addresses

項目 内容
Validating URLs URLのValidationについて
Matching IPv4 Addresses IPv4のバリデーションについて

参考書籍

※紙の書籍だと4410円。Androidアプリの電子書籍なら413円

Regular Expressions Cookbook

Regular Expressions Cookbook