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
370
正規表現の少し進んだ機能 / 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
470
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
80
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
260
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
400
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
650
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
560
UICollectionView Compositional Layout
usamik26
0
610
Coding Swift with Visual Studio Code and Docker
usamik26
0
400
Swift Extension for Visual Studio Code
usamik26
2
810
Other Decks in Programming
See All in Programming
大規模マルチテナントを解決するYugabyteDBという選択肢
nnaka2992
1
250
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
ピグパーティにおけるMongoDB CommunityバージョンからAtlasへの移行事例
10969hotaka
0
130
【Go言語】golangci-lintの使い方
tomo1227
0
270
スクラムマスターって孤独じゃないですか?
yoshitaroyoyo
1
140
継続的な活動で築く地方エンジニアの道
myamashii
2
350
Cloudflare Workers x AWS Lambdaの組み合わせユースケース / Cloudflare Workers x AWS Lambda Combination Use Case
seike460
PRO
2
310
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
CSC307 Lecture 09
javiergs
PRO
1
500
社内 LT 会を発足し、アウトプット文化を醸成させるために考えたこと・やったこと / Starting internal LT meetings and fostering an output culture
mackey0225
3
120
[After Kotlin Fest 2024 LT Night @ Sansan] もっともっとKotlinを好きになる!K2 Compiler Pluginで遊んでみよう!
kitakkun
2
260
しくじり先生 Image Matching Challenge 2024 編
goosehaaan
0
810
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
21
2.9k
Music & Morning Musume
bryan
43
5.9k
Fontdeck: Realign not Redesign
paulrobertlloyd
79
5.1k
Adopting Sorbet at Scale
ufuk
71
8.8k
How GitHub Uses GitHub to Build GitHub
holman
471
290k
Web development in the modern age
philhawksworth
203
10k
Building Flexible Design Systems
yeseniaperezcruz
323
37k
Producing Creativity
orderedlist
PRO
340
39k
What's new in Ruby 2.0
geeforr
338
31k
Navigating Team Friction
lara
181
13k
StorybookのUI Testing Handbookを読んだ
zakiyama
15
4.9k
Clear Off the Table
cherdarchuk
89
320k
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) 解説
書籍
便利ツール