An Introduction to regex

Speakers: William Smith

Level: Intermediate, Lecture

Excerpt: Regex, like chess, is easy to learn but can take a lifetime to master. It’s a handy way to identify “something” when you don’t necessarily know what that “something” is (think of wildcards). Mac admins have a lot of existing tools that support regex like BBEdit, Jamf Pro and most any command line shell. Let’s look at uses for regexes, the basics of how to create them and where we can use them.

Description: Regex (short for regular expression), like chess, is easy to learn but can take a lifetime to master. Regex is a handy way to identify “something” when you don’t necessarily know what that “something” is.
Whaaaaa!?
Maybe your inventory system collects the model identifiers of all your MacBook Pros. Which ones are macOS Catalina compatible? Apple’s website lists 23 compatible and 17 non-compatible model identifiers. Do you really want to create a report listing each one? What if Apple updates their list?
Regex to the rescue! Here you go: MacBookPro(9|\d{2,}),\d
Maybe you need to identify all your Macs running Microsoft Office 2016 so you can upgrade them to Office 2019. The problem is neither “2016” nor “2019” are anywhere in the titles of the applications nor in their their version numbers. And Microsoft is updating both suites every month. Do we just keep track of a long list of version numbers?
Bada boom! Office 2019: ^16\.(1[7-9].*|[2-9][0-9].*)
Bada bing! Office 2016: ^1(5.*|6\.(9$|9\.1|1[0-6].*))
Mac admins have a lot of existing tools that support regex like BBEdit, Jamf Pro and most any command line shell. Regex is the perfect party game in nerd circles Who can make the shortest string? And it’s a great conversation starter Is it important to match the entire string or just enough to be certain?
Let’s look at uses for regexes (regexen?), the basics of how to create them and where we can use them. We can discuss the philosophy of regex over drinks (BYOB).


About the speaker

William Smith (Twitter: @meck) – Professional Services Engineer – Jamf

Bill is a Professional Services Enginerd with Jamf and works with education, enterprise and government clients.
In his travels visiting with hundreds of customers across the globe to help develop solutions for their unique problems, he picks up a few tips and tricks along the way and enjoys sharing them. He’s been supporting Macs and their users for more than 25 years.
Bill enjoys teaching and writing about tech. He’s spoken at Jamf Nation User Conference, MacIT, MacTech, Penn State MacAdmins and other conferences, written for MacTech Magazine (does anyone remember that?) and is co-author of the second edition of the Enterprise Mac Administrator’s Guide. He is also a co-founder of Twin Cities Mac Admins, a community supporting all things Apple from Education to Enterprise.

This entry was posted in MacAdmins 2020 Sessions. Bookmark the permalink.