Master regex: From basics to advanced pattern matching
While regular expressions can certainly look like hieroglyphics, once you understand the basics, you can unlock massive amounts of power in your searches and work.
You’re working with some data and find yourself needing to find a specific piece of information, but your searches keep matching things that you don’t want. While basic searches are fine for some things, every once in a while you need something more powerful.
Enter regular expressions (also referred to as “regex”). BUT WAIT! Before you scroll to the next session description: did you know that this powerful searching capability is available in things like Word and Excel, as well as Google Search Console and Google Analytics? And not only can you use it to search for information, you can also use it to transform information!
In this session, Marine Gandy jump into a brief history of regex, discuss pattern matching, and dive into the fundamentals of how we can use regex to surface the data we’ve been searching for in powerful ways
Enterprise Symfony for the future: Platform.sh is the official Symfony Cloud Platform.
A bright, new offer powered by Platform.sh—adopted (and ❤️) by 16,000+ developers, 7,000 customers, and proven over the last 8 years—Upsun provides out-of-the-box capabilities that serve as the launchpad for creative development teams’ out-of-the-box thinking. A single, fully managed, self-service PaaS for development teams who just want to build their next, great application.
Links to check out: 👉 Get your free Upsun trial: https://brnw.ch/21wFxKr 👉 Learn more about Blackfire: https://brnw.ch/21wFxKp 👉 Get started with Platform.sh: https://brnw.ch/21wFxKj
Key moments: 0:00 - Intro
- Introducing regex with the aim of simplifying its complexities.
- Clarifying terminology and encouraging active participation.
- Providing resources for exploration and learning.
4:15 - Introduction to Regular Expressions
- Originating in 1951, regular expressions define search patterns with character sequences.
- Emphasizing accessibility and comprehension for all, regardless of mathematical background.
6:03 - Regular Expression uses
- Practical applications include text finding, validation, and string manipulation.
- Surprising platforms like Google Docs, Word, Excel, and Google Sheets support regex.
- Highlighting versatility and usefulness in various contexts.
6:30 - How to use Regular Expressions
- Reviewing regex syntax: literal characters, special characters, and character classes.
- Encouraging hands-on experimentation and understanding syntax nuances.
8:58 - RegEx builders
- Mentioning regex engines and their role in computing patterns.
- Cautioning about differences in engine behavior and recommending online tools for experimentation.
9:21 - RegEx Special characters
- Explaining special characters’ significance, including anchors (^, $) for string or line boundaries.
- Discussing nuances of special characters’ behavior within regex patterns.
11:13 - RegEx Character classes
- Describing character classes introduced by opening square brackets to define character sets.
- Clarifying the behavior of special characters within character classes and providing examples.
12:34 - RegEx Negation
- Introducing negation using the caret (^) within character classes to exclude specific characters.
- Cautioning about the interpretation of the caret and emphasizing attention to detail.
13:37 - Shorthand character classes
- Explaining shorthand character classes (\d, \s) for common character sets.
- Advantages in simplifying regex patterns and improving readability.
- Cautioning about variations in shorthand class behavior across regex engines.
15:22 - RegEx Alternation
- Introduces the pipe (|) symbol for alternation.
- Explains alternation as “either/or” for pattern matching.
- Caution about returning the first matching result.
16:30 - RegEx Quantifiers
- Overview of quantifiers: ?, *, and +.
- Explains how they affect pattern repetition.
- Warns about “greediness” in matching behavior.
21:23 - RegEx Grouping
- Introduction to grouping using parentheses.
- Illustrates combining grouping with alternation.
- Example: matching spelling variations.
22:24 - RegEx Capturing
- Defines capturing groups for reusing matched patterns.
- Emphasizes their role in pattern manipulation.
- Compares grouping vs. capturing.
23:38 - Game time
- Uses regex for word puzzles and games.
- Encourages experimentation for skill development.
25:18 - Resources and acknowledgements
- Acknowledges resources and contributors.
- Encourages further exploration of regex resources.
26:00 - Questions