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
正規表現の後読みは正義
Search
Akio Takahashi
January 10, 2025
14
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
正規表現の後読みは正義
社内LTで正規表現の便利さについて発表しました。
Akio Takahashi
January 10, 2025
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
77
5.6k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
630
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Design in an AI World
tapps
1
350
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Transcript
正規表現の後読みは正義 2024/12/19 高橋 明生
みんな知ってる正規表現 .* [abc] [a-z]+ (Hello|Goodbye) World!?
なんと文字列抽出にも使える input : abc123def pattern: [0-9]+ match : 123 input
: “viewing_rate”: 123.34 pattern: [1-9][0-9]*(¥.[0-9]+)? match : 123.34
JSONから特定の属性の値を取り出したい {"seriesId":2,"monitorId":40999,"householdId":1 9999,"openedAt":"2024-12-13 04:55:44.751000","c losedAt":"2024-12-13 05:00:00.000000","baseunit Id":101009999}
単純一致でがんばる pattern: [0-9]+ match : 他の数字も入ってきちゃう {"seriesId":2,"monitorId":40999,"householdId":1 9999,"openedAt":"2024-12-13 04:55:44.751000","c losedAt":"2024-12-13
05:00:00.000000","baseunit Id":101009999}
単純一致でがんばる pattern: "householdId":[0-9]+ match : "householdId":19999 数字だけ取り出せてない {"seriesId":2,"monitorId":40999,"householdId":1 9999,"openedAt":"2024-12-13 04:55:44.751000","c
losedAt":"2024-12-13 05:00:00.000000","baseunit Id":101009999}
そこで後読み pattern: (?<="householdId":)[0-9]+ result : 19999 {"seriesId":2,"monitorId":40999,"householdId":1 9999,"openedAt":"2024-12-13 04:55:44.751000","c losedAt":"2024-12-13
05:00:00.000000","baseunit Id":101009999}
仕様 • 先読みアサーション (?= ...) (?! ...) • 後読みアサーション (?<=
...) (?<! ...) input : 1行にひとつのメールアドレス pattern: ^.+@.+(?<!switch-m¥.com)$ result : スイッチ以外のメアド input : 1,2,3,4,5, pattern: (?!=2)[0-9]+, result : 1 3 4 5 知らないと人生損するので ぜひ使ってください