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
490
正規表現の少し進んだ機能 / 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
630
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
180
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
320
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
480
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
740
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
670
UICollectionView Compositional Layout
usamik26
0
780
Coding Swift with Visual Studio Code and Docker
usamik26
0
510
Swift Extension for Visual Studio Code
usamik26
2
1k
Other Decks in Programming
See All in Programming
AWS CDKの推しポイント 〜CloudFormationと比較してみた〜
akihisaikeda
3
230
Rails産でないDBを Railsに引っ越すHACK - Omotesando.rb #110
lnit
1
160
XSLTで作るBrainfuck処理系
makki_d
0
190
Cursor Meetup Tokyo ゲノミクスとCursor: 進化と制約のあいだ
koido
2
990
Elixir で IoT 開発、 Nerves なら簡単にできる!?
pojiro
1
120
Perlで痩せる
yuukis
1
680
レガシーシステムの機能調査・開発におけるAI利活用
takuya_ohtonari
0
590
A comprehensive view of refactoring
marabesi
0
170
実践ArchUnit ~実例による検証パターンの紹介~
ogiwarat
2
250
Prism.parseで 300本以上あるエンドポイントに 接続できる権限の一覧表を作ってみた
hatsu38
1
110
イベントストーミングから始めるドメイン駆動設計
jgeem
4
820
プロダクト開発でも使おう 関数のオーバーロード
yoiwamoto
0
150
Featured
See All Featured
Building Applications with DynamoDB
mza
95
6.4k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Practical Orchestrator
shlominoach
188
11k
A Tale of Four Properties
chriscoyier
159
23k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
4
140
Reflections from 52 weeks, 52 projects
jeffersonlam
350
20k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Embracing the Ebb and Flow
colly
86
4.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.8k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
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) 解説
書籍
便利ツール