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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
USAMI Kosuke
August 19, 2022
Programming
560
1
Share
正規表現の少し進んだ機能 / regex lookahead
※ Docswell に移行しました
https://www.docswell.com/s/usami-k/58GRDQ-regex-lookahead
USAMI Kosuke
August 19, 2022
More Decks by USAMI Kosuke
See All by USAMI Kosuke
Onsager代数とその周辺 / Onsager algebra tsudoi
usamik26
0
690
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
250
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
380
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
540
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
800
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
720
UICollectionView Compositional Layout
usamik26
0
860
Coding Swift with Visual Studio Code and Docker
usamik26
0
560
Swift Extension for Visual Studio Code
usamik26
2
1.1k
Other Decks in Programming
See All in Programming
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3.4k
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
100
Liberating Ruby's Parser from Lexer Hacks
ydah
2
1.3k
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
130
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
560
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
810
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
790
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
6.5k
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
110
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
200
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
510
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
340
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Writing Fast Ruby
sferik
630
63k
The SEO identity crisis: Don't let AI make you average
varn
0
440
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
450
For a Future-Friendly Web
brad_frost
183
10k
What's in a price? How to price your products and services
michaelherold
247
13k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
710
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) 解説
書籍
便利ツール