Updated: 📆 2018-04-06.
Regular Expressions, RegEx, regexps– call them what you like, but no matter how you slice it, they’re useful af. After all, data spelunking is all about patterns, and that’s precisely what regexps are for: (wo)manhandling patterns in strings. Good Sirs Wickham and Grolemund, in their masterful tome, r4ds, describe them thusly:
They [regexps] take a little while to get your head around, but once you understand them, you’ll find them extremely useful.1
There are helpful string-related R packages 📦, stringr
(which is built on top of the more comprehensive stringi
package) comes to mind. But, at some point in your computing life, you’re gonna need to get down with regular expressions.
🆕 An RStudio addin by Garrick Aden-Buie, RegExplain, looks like it will be an invaluable companion to go along with the other resources collected here.
Below you’ll find a collection of some of the Regex-related links I’ve tweeted 🐦:
Basic Regular Expressions in R Cheat Sheet by Ian Kopacka
Super useful cheat sheet: "Basic Regular Expressions in R" by Ian Kopacka https://t.co/Ve3Lqkt43S #RegEx #rstats pic.twitter.com/CxFt9valYi
— Mara Averick (@dataandme) April 14, 2017
strings and regular expressions by Lise Vaudor
Another great visual 👁🗨 cheat sheet by @LVaudor: «strings et expressions régulières» https://t.co/EiGrTvCknW #rstats #regex pic.twitter.com/pTjvRvE0W7
— Mara Averick (@dataandme) September 3, 2017
Quick Guide to Regex in R by Ben Gorman
"Quick Guide to Regex in R" by @gormanalysis https://t.co/FVVAUBjrGd #rstats #RegEx pic.twitter.com/1em5MZBj5j
— Mara Averick (@dataandme) December 16, 2016
An Introduction to stringr and Regular Expressions by Brian Espinoza
👍 intro deck, w/ exercises 🏋️♀️: "An Introduction to stringr & Regular Expressions" – Brian Espinoza https://t.co/2OicEBYeQ8 #rstats #regex pic.twitter.com/hBJAyY6wY9
— Mara Averick (@dataandme) July 28, 2017
qdapRegex 📦 by Tyler Rinker
Some handy RegEx tools in R: “qdapRegex” https://t.co/6az5jmiq6M #rstats #regex pic.twitter.com/LtJ1UdRScg
— Mara Averick (@dataandme) June 12, 2017
RegexOne simple, interactive exercises
Nice, interactive resource for learning Regular Expressions: “RegexOne” https://t.co/80YyOyBLGx via @RegexOne cc @BecomingDataSci #RegEx pic.twitter.com/ZiDm273qsW
— Mara Averick (@dataandme) November 17, 2016
Regular expressions in swirl
by Jon Calder
👩💻 learn about regexps in R *from* R 🌀 "Regular expressions" by @jonmcalder & @swirlstats https://t.co/P5W9khJAHh #rstats #regex pic.twitter.com/lRPIxRp2j5
— Mara Averick (@dataandme) September 29, 2017
Awesome new stringr
cheat sheet from RStudio
🎉 Woo! New @rstudio cheat sheet
— Mara Averick (@dataandme) October 27, 2017
📋 "Work w/ strings"
Feat. #stringr & @LVaudor's 💫 graphics! https://t.co/JCO2ux6V8X #rstats pic.twitter.com/ZDajFRETSw
Tada 🎉
As always, by all means let me know if you’ve written something you think I should add: chirp my way (🐦 @dataandme), comment– you know the drill.
Wickham, Hadley and Garrett Grolemund. 2016. R for Data Science. Sebastopol: O’Reilly Media. Web. http://r4ds.had.co.nz/strings.html#matching-patterns-with-regular-expressions 20 September, 2017.↩