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 201
Search
Jake Bathman
December 21, 2018
Programming
0
59
Regex 201
A few quick tips on Regex for experienced peeps, given as a Tighten Talk on Dec 21, 2018
Jake Bathman
December 21, 2018
Tweet
Share
More Decks by Jake Bathman
See All by Jake Bathman
Delete Your Data
jakebathman
0
21
Streaming 101
jakebathman
0
28
GitFlow and You
jakebathman
0
490
Other Decks in Programming
See All in Programming
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
140
これならできる!個人開発のすゝめ
tinykitten
PRO
0
140
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.8k
AIコーディングエージェント(Gemini)
kondai24
0
300
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
920
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.5k
ローカルLLMを⽤いてコード補完を⾏う VSCode拡張機能を作ってみた
nearme_tech
PRO
0
200
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
420
Implementation Patterns
denyspoltorak
0
140
Vibe codingでおすすめの言語と開発手法
uyuki234
0
140
Pythonではじめるオープンデータ分析〜書籍の紹介と書籍で紹介しきれなかった事例の紹介〜
welliving
3
660
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
430
Featured
See All Featured
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
54
48k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
79
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
38
Amusing Abliteration
ianozsvald
0
76
Exploring anti-patterns in Rails
aemeredith
2
210
Designing for humans not robots
tammielis
254
26k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
300
Into the Great Unknown - MozCon
thekraken
40
2.2k
How to train your dragon (web standard)
notwaldorf
97
6.5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
sira's awesome portfolio website redesign presentation
elsirapls
0
94
Transcript
https://dev.to/rly
TOPICS • Anchors • Match groups • Lookahead and lookbehind
ANCHORS ^ $ \b Start of string End of string
Word boundary ^([\w]+)\b([\w]+)$ Jake Bathman
MATCH GROUPS • In PHP, Javascript, and other languages, you
can name your match groups in regex matches /Call me (?<firstname>[\w]+)/ Call me Jake PHP & JS syntax: PHP example: preg_match( '/Call me (?<firstname>[\w]+)/', "Call me Jake", $matches ); echo($matches['firstname']);
LOOK AHEAD/BEHIND (?=foo) Lookahead Lookbehind Positive Negative (?!foo) (?<!foo) (?<=foo)
LOOK AHEAD/BEHIND (?=foo) Lookahead Lookbehind Positive Negative (?!foo) (?<!foo) (?<=foo)
/foo(?=bar)/ foobar foobaz ✅ ❌
LOOK AHEAD/BEHIND (?=foo) Lookahead Lookbehind Positive Negative (?!foo) (?<!foo) (?<=foo)
/foo(?!bar)/ foobar foobaz ✅ ❌
LOOK AHEAD/BEHIND (?=foo) Lookahead Lookbehind Positive Negative (?!foo) (?<!foo) (?<=foo)
/(?<=foo)bar/ foobar fuubar ✅ ❌
LOOK AHEAD/BEHIND (?=foo) Lookahead Lookbehind Positive Negative (?!foo) (?<!foo) (?<=foo)
/(?<!not )foo/ not foo but foo ✅ ❌
BONUS: MY MOST INSANE REGEX (^([A-Za-z0-9]+)\:?)|(inet|inet6)\s*(?:addr:?)?\s*((\d{1,3}\.){3}\d{1,3}|((([0-9A-Fa-f]{1,4}:){7}([0-9A- Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]) (\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}) {1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])) {3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|
1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:) {3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]) (\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}) {1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]| 1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f] {1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? [0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9] [0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?) eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 45.56.76.94 netmask 255.255.255.0 broadcast 45.56.76.255 inet6 fe80::f03c:91ff:fea1:e9d1 prefixlen 64 scopeid 0x20<link> inet6 2600:3c00::f03c:91ff:fea1:e9d1 prefixlen 64 scopeid 0x0<global> ether f2:3c:91:a1:e9:d1 txqueuelen 1000 (Ethernet) RX packets 145749659 bytes 171250537930 (159.4 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 60215383 bytes 12025642918 (11.1 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: inet 45.56.76.94 inet6 fe80::f03c:91ff:fea1:e9d1 inet6 2600:3c00::f03c:91ff:fea1:e9d1 ifconfig myip
RESOURCES • Regex101 (make an account and save your stuff!)
https://regex101.com/