Tutorial 2026-04-05
正規表現のLookahead/Lookbehindパターン解説
正規表現のlookahead/lookbehindを実践例で学びましょう。
LookaheadとLookbehindはゼロ幅パターンで、文字を消費せずに位置にマッチします。
アサーションの種類
(?=...) Positive lookahead
(?!...) Negative lookahead
(?<=...) Positive lookbehind
(?
パスワード検証の例
const strongPassword = /^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.[@$!%?&])[A-Za-z\d@$!%?&]{8,}$/;
Regexテスターツールでパターンを試しましょう。