Please enable JavaScript to view this site.

 

Navigation: Appendices > Typography

Regular Expressions (regex)

Scroll Prev Up Next More

Regular expressions, which can be used in SARAs and in the search dialogs of recurring holidays, one-time-dates, saints and slogans, is a powerful set of commands used to make searches much more general.

 

A list of online references to learn about regular expressions can be found at the end of this topic.

 

Most of us are familiar with the basics of regular expressions, such as searching for *.txt to find text files. Some more complex examples are:

 

Find text between straight double-quotes and replace this with the text, without the quotes, in italics (for example)

Sample result log below

Sample result log below

 

 

Find "rd" preceded by "3" and make "rd", without the preceding "3" into superscript (for example)

Sample result log below

Sample result log below

 

Replace 2 spaces that are between a Thursday and a Moon phase symbol and replace those 2 spaces (only) by a single space so that the Moon phase remains in box.

 

Search for repeated 2-digit numbers from 19-24 separated by a front slash, and replaces it by a single instance of that repeated number, without the front slash.

 

Our favorite Regular Expression Quick Reference is here (for conciseness) and here as on online tester validator.

 

A pedagogical, but verbose, introduction to regular expressions can be found here, while a more concise, but exhaustive, list of regular expressions commands and options can be found here. Finally, this site has a nice mix of simple bite-size examples as well as some very advanced topics.

 


Topic 181300, last updated on 08-Oct-2020