Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
正規表現の少し進んだ機能 / regex lookahead
Search
USAMI Kosuke
August 19, 2022
Programming
580
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
正規表現の少し進んだ機能 / 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
730
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
290
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
420
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
570
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
840
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
750
UICollectionView Compositional Layout
usamik26
0
910
Coding Swift with Visual Studio Code and Docker
usamik26
0
620
Swift Extension for Visual Studio Code
usamik26
2
1.2k
Other Decks in Programming
See All in Programming
AmebaブログはKMPから卒業します
kmars0605
0
220
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
1.1k
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
190
No More NoSuchMethodError
exoego
1
110
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
660
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
120
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
120
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
400
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
470
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
380
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
110
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
150
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
12k
What's in a price? How to price your products and services
michaelherold
247
13k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
440
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Code Review Best Practice
trishagee
74
20k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Statistics for Hackers
jakevdp
799
230k
A designer walks into a library…
pauljervisheath
211
25k
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
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) 解説
書籍
便利ツール