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
570
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
700
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
270
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
400
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
560
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
820
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
740
UICollectionView Compositional Layout
usamik26
0
880
Coding Swift with Visual Studio Code and Docker
usamik26
0
590
Swift Extension for Visual Studio Code
usamik26
2
1.1k
Other Decks in Programming
See All in Programming
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
0
280
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
380
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
170
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
220
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
1.1k
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
210
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
650
AIエージェントで 変わるAndroid開発環境
takahirom
2
680
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
170
1B+ /day規模のログを管理する技術
broadleaf
0
140
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
250
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.4k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Done Done
chrislema
186
16k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
470
Unsuck your backbone
ammeep
672
58k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Curse of the Amulet
leimatthew05
2
13k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.6k
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) 解説
書籍
便利ツール