Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
正規表現の少し進んだ機能 / regex lookahead
Search
USAMI Kosuke
August 19, 2022
Programming
1
510
正規表現の少し進んだ機能 / regex lookahead
※ Docswell に移行しました
https://www.docswell.com/s/usami-k/58GRDQ-regex-lookahead
USAMI Kosuke
August 19, 2022
Tweet
Share
More Decks by USAMI Kosuke
See All by USAMI Kosuke
Onsager代数とその周辺 / Onsager algebra tsudoi
usamik26
0
650
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
190
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
340
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
490
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
760
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
680
UICollectionView Compositional Layout
usamik26
0
800
Coding Swift with Visual Studio Code and Docker
usamik26
0
520
Swift Extension for Visual Studio Code
usamik26
2
1.1k
Other Decks in Programming
See All in Programming
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
13
5.6k
Claude Codeで挑むOSSコントリビュート
eycjur
0
190
1から理解するWeb Push
dora1998
1
260
Jakarta EE Core Profile and Helidon - Speed, Simplicity, and AI Integration
ivargrimstad
0
300
MLH State of the League: 2026 Season
theycallmeswift
0
210
More Approvers for Greater OSS and Japan Community
tkikuc
1
110
サーバーサイドのビルド時間87倍高速化
plaidtech
PRO
0
690
CSC305 Summer Lecture 12
javiergs
PRO
0
130
ProxyによるWindow間RPC機構の構築
syumai
2
620
Introducing ReActionView: A new ActionView-compatible ERB Engine @ Rails World 2025, Amsterdam
marcoroth
0
290
AI時代のUIはどこへ行く?
yusukebe
9
5.5k
AIレビュアーをスケールさせるには / Scaling AI Reviewers
technuma
2
240
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
Typedesign – Prime Four
hannesfritz
42
2.8k
How STYLIGHT went responsive
nonsquared
100
5.8k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
GitHub's CSS Performance
jonrohan
1032
460k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Transcript
正規表現の 少し進んだ機能 宇佐見公輔 / 株式会社ゆめみ
自己紹介 宇佐見公輔 / 株式会社ゆめみ / iOS テックリード 大阪在住、最寄のゆめみオフィスは京都(まだ物理出社してないが) 来月のiOSDC にパンフレット記事寄稿、トーク登壇予定
来月の技術書典に出展予定
正規表現を再勉強中 Swift で正規表現が言語組み込みになる この機会に、正規表現を再勉強 意外と知らない機能がいろいろあった 例:名前付きキャプチャ、後方参照 書いた:Swift Regex でキャプチャや名前付きキャプチャを使う -
Qiita
正規表現の基本 文字列のパターンマッチ 部分文字列の抽出(キャプチャ)
位置へのマッチ アンカー:「文字列」でなく「位置」にマッチする 長さ0 の文字列にマッチすると考えて、ゼロ幅アサーションとも呼ばれる ^ (先頭) $ (末尾) \b (単語の境界)など
` ` ` ` ` `
少し進んだ機能の紹介 先読み(lookahead ) 後読み(lookbehind )
先読み 先読み(lookahead )は、位置にマッチする記法の一種で、位置の指定に正 規表現が使える。 (?= と ) で囲む。 ` `
` ` a(?=..d) → 「a 」の次に「任意の2 文字+d 」が来る場合に限り、「a 」にマッチする
後読み (?=regex) : 先読み。次に regex がくる位置にマッチ。 (?<=regex) : 後読み。前に regex
がくる位置にマッチ。 ` ` ` ` ` ` ` `
否定先読み・否定後読み (?!regex) : 否定先読み。次に regex がこない位置にマッチ。 (?<!regex) : 否定後読み。前に regex
がこない位置にマッチ。 ` ` ` ` ` ` ` `
先読みが便利な場合 (1) 複数の正規表現すべてにマッチするか
先読みが便利な場合 (2) 数値の3 桁ごとにカンマを挿入するコード → これ、どうなってるの?
先読みが便利な場合 (2) 解説
書籍
便利ツール