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
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
370
@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
850
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
猫の手も借りたい!ので AIエージェント猫を作って社内に放した話 Claude Code × Container Lambda の Slack Bot "DevNeko"
naramomi7
0
230
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
110
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
220
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
190
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
190
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
2.9k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
120
CSC307 Lecture 11
javiergs
PRO
0
580
CSC307 Lecture 10
javiergs
PRO
1
690
15年目のiOSアプリを1から作り直す技術
teakun
0
570
JPUG勉強会 OSSデータベースの内部構造を理解しよう
oga5
2
220
2026/02/04 AIキャラクター人格の実装論 口 調の模倣から、コンテキスト制御による 『思想』と『行動』の創発へ
sr2mg4
0
650
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
Writing Fast Ruby
sferik
630
62k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Optimizing for Happiness
mojombo
379
71k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
[SF Ruby Conf 2025] Rails X
palkan
2
800
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
300
Chasing Engaging Ingredients in Design
codingconduct
0
130
So, you think you're a good person
axbom
PRO
2
1.9k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
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) 解説
書籍
便利ツール