Vim

Vim: Regex Patterns

Regular expressions are an insanely useful tool. It is absolutely worth the effort to learn how to use them, even a modicum of competence with regular expressions will pay dividends for your entire career. When you come across a problem that fits well with the use regular expressions it will save you hours and hours of work (not to mention how satisfying it is solve a gnarly problem with a few lines of code). The challenge is that without some mastery you don’t always spot the opportunities.

The more you understand regular expressions, the more leverage you will gain from the text processing tools (Vim, Sed, Awk, and Grep in particular), although regular expression support is included in many more tools. Most modern languages have great inbuilt support for regular expressions as well.

There are many implementations of regular expressions. This works out mostly ok, you know the tools you regularly use well and most regex implementations cover the basics well so it’s only the more esoteric features that may or may not be available in your current tool (or more frustratingly, work in s slightly different way). In practice, I have not found this to be a big deal.

The Basics

Meta-characters:

Character Class

A character class is the set of characters allowed at that particular point. Only one character is used.

Back Referencing

Escaping Meta-characters

Resources

Master Regular Expressions, 3ed.,

Tools

Web

Languages

Data