背骨から周辺へ
내의게에엔을를 아가나라마사자하다 어거너더러머서저허 해했 오고노도로모보호소조요 우구누두루무부후수주유 이기니디리미비히시지 으그느드르므브흐스즈 없세았었였울운맛있겠 인안한대은는 입십읍습
CONVERT
Quantifiers .+? 最短一致
\b = word border (' ', \t, /) (\w と \W の間の空文字列と一致)
\s 空白文字(半角スペース、\t、\n、\r、\f)すべて [ \t\f\r\n\v]
\w すべての半角英数字とアンダースコア [a-zA-Z0-9_]
/^[^\x01-\x7E\xA1-\xDF]+$/ 全角文字に相当している正規表現
■後方参照 with () without g
str.match, regex.exec(String.match/RegExp.exec共通)
[0] : マッチした文字列
[1] : 1番目の部分文字列(マッチ結果)
[2] : 2番目の部分文字列(マッチ結果)
■複数配列 with () and g option
str.match returns no () capture
[0] : first whole match
[1] : second whole match
[2] : third whole match
lastIndex moves until end.
regex.exec returns
[0] : whole match
[1] : first() match
[2] : second() match
lastIndex moves for the next exec.
[] square bracket 内のエスケープ
以下の4つの記号だけがメタキャラクタ(=機能を持つ記号)として扱われます。
\(backslash)
-(hyphen-minus)
^(俗に山形記号、キャレット)(circumflex, hat sign、caret)
文字クラスの先頭以外の場所ならエスケープ不要
] 閉じ角かっこ(right square bracket)
それ以外の記号はエスケープなし可能
🔶🔷後方参照 backreference $1, $2
text that was matched by the capturing groups
🔶🔷先読み LookAhead: followed by ()
Look ahead positive (?=)
bb(?=c) lookahead(先読み) is OK, (?<=a)bb lookbehind(後読み) is NG
(?<!xxx)AAA : not preceded by xxx 否定の後読み
AAA(?!xxx) : not followed by xxx 否定の先読み
A(?=B)
Find expression A where expression B follows:
Look ahead negative (?!)
A(?!B)
Find expression A where expression B does not follow:
なつ(?=みかん)
(?=pattern) look ahead: マッチの条件; not マッチの範囲 when replace
(?!pattern) look ahead negative
(?:pattern) only group; no partial
🔶🔷後読み LookBehind: preceded by ()
Look behind positive (?<=)
(?<=B)A
Find expression A where expression B precedes:
Look behind negative (?<!)
(?<!B)A
Find expression A where expression B does not precede: