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
Regular Expressions
Search
John Chandler
November 22, 2012
Programming
18
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Regular Expressions
Internal presentation on regular expressions, 2012
John Chandler
November 22, 2012
More Decks by John Chandler
See All by John Chandler
Everything I've Learnt from Russel Winder's Talks, in 5 Minutes (A Tribute)
metaljoe
0
17
Snowboarding Saved My Software Career
metaljoe
0
14
Neurodiversity in Tech
metaljoe
0
68
Neurodiversity Lightning Talk
metaljoe
0
18
Tackling a Legacy Codebase with (Micro)Services
metaljoe
0
14
Testing Workshop - Part 1 (PyConUK 2011)
metaljoe
0
24
Testing Workshop - Part 2 (PyConUK 2011)
metaljoe
0
16
Python, DOT, and Visualising Legacy Code The Lazy Way
metaljoe
0
23
Test Driven Development (A Short Introduction)
metaljoe
0
16
Other Decks in Programming
See All in Programming
setup-vp GitLab対応の裏側
naokihaba
0
140
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
520
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
320
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
290
すこし踏み込む CancellationToken
htkym
2
1.5k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
310
速習iPhone Duo対応
yuukiw00w
2
910
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
740
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
580
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
280
Verilogで学ぶCPU自作入門.pdf
uyuki234
7
3.9k
Java 27新機能 / Java 27 new features
kishida
2
190
Featured
See All Featured
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
530
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
240
Building Adaptive Systems
keathley
44
3.2k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
© John Chandler 2012 Regular Expressions
http://xkcd.com/208/
What? A pattern describing a set of text strings
When? From formal regular set theory in 1950s Popularised by
beardy UNIX types in 1970s
Why? Matching / searching text Search and replace Parsing strings
Main Flavours POSIX Basic / Extended (default with UNIX tools)
Perl-derived – very popular! (Perl, Python, PHP, JavaScript, .NET)
Syntax: The First 90% c standard characters . any character
^ start of string $ end of string c* zero or more of c
Syntax: The First 90% ^Pip*e.*$ matches: Piper at the Gates
of Dawn Pie and Chips
Syntax: The First 90% ^Pip*e.*$ doesn't match: A Pipe pie
spam chips and spam
Choices | or, alternative [abc] character class [^abc] inverse of
class
Choices foo|bar matches: foo fighters toolbar bar fool
Special Sequences \b beginning / end of word \d decimal
digit \s whitespace \w alphanumeric and underscore
Repetition s * zero or more + one or more
? zero or one {n} exactly n-times {n,m} n to m times
Groups (abc) capturing group (?:abc) non-capturing group (?P<name>) named capturing
group (?P=name) match a previous match
What do these do? (foo|bar) ((?:abc){3,4}) (?P<foo>\w+) [“']([^”']+)[“']
What about these? (fish) \1 (?P<thing>fish) (?P=thing) Isaac (?=Asimov) Isaac
(?!Asimov)
Greedy Matching By default, regular expressions are greedy. They will
find the biggest match that satisfies an expression.
Non-greedy Repetitions *? zero or more +? one or more
?? zero or one
Writing Regexes Don't if there is a simpler way Build
regex from small chunks Use the Python and PHP REPLs Document!
Debugging Regexes Don't panic Break regex into smaller chunks Use
the Python and PHP REPLs Watch out for special characters!
Anything else? Any questions? Read the Python and PHP docs
Try the UNIX grep command