The cheat sheet below is based off this great cheat sheet for regular expressions in R by Ian Kopacka.
This is not supposed to be used as an introduction to regular expressions (have a look at the relevant help files and some of the materials shared below for this).
This is also not a complete set of anchors, characters etc for matching, but those shown should be sufficient for most tasks (certainly for what I do at least!).
A few useful links related to regular expressions in Stata:
- Introduction to regular expressions by StataCorp
- Complete list of string functions in Stata (not just regular expressions)
- More comprehensive (in some respects) cheat sheet by Asjad Naqvi
- Presentation on regular expressions by Rose Anne Medeiros
To open the pdf below in its own page click here.