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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
USAMI Kosuke
August 19, 2022
Programming
1
560
正規表現の少し進んだ機能 / 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
680
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
230
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
360
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
530
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
790
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
710
UICollectionView Compositional Layout
usamik26
0
840
Coding Swift with Visual Studio Code and Docker
usamik26
0
550
Swift Extension for Visual Studio Code
usamik26
2
1.1k
Other Decks in Programming
See All in Programming
ふん…おもしれぇ Parser。RubyKaigi 行ってやるぜ
aki_pin0
0
110
Metaprogramming isn't real, it can't hurt you
okuramasafumi
0
120
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
300
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
2
790
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
400
Raku Raku Notion 20260128
hareyakayuruyaka
0
410
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
130
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
360
AI & Enginnering
codelynx
0
140
Oxlintはいいぞ
yug1224
5
1.4k
CSC307 Lecture 12
javiergs
PRO
0
440
AI時代の認知負荷との向き合い方
optfit
0
180
Featured
See All Featured
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
230
Thoughts on Productivity
jonyablonski
75
5.1k
Statistics for Hackers
jakevdp
799
230k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
60
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
130
[SF Ruby Conf 2025] Rails X
palkan
2
790
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.4k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
360
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
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) 解説
書籍
便利ツール