Appendix A. Regular Expression Reference
This appendix is a reference for regular expressions.
Regular Expressions in QED
QED (short for Quick Editor) was originally written for the Berkeley Time-Sharing System, which ran on the Scientific Data Systems SDS 940. A rewrite of the original QED editor by Ken Thompson for MIT’s Compatible Time-Sharing System yielded one of the earliest (if not the first) practical implementation of regular expressions in computing. Table A-1, taken from pages 3 and 4 of a 1970 Bell Labs memo, outlines the regex features in QED. It amazes me that most of this syntax has remained in use to this day, over 40 years later.
Table A-1. QED regular expressions
Feature | Description |
---|---|
literal | “a) An ordinary character [literal] is a regular expression which matches that character.” |
^ | “b) ^ is a regular expression which matches the null character at the beginning of a line.” |
$ | “c) $ is a regular expression which matches the null character before the character <nl> [newline] (usually at the end of a line).” |
. | “d) . is a regular expression which matches any character except <nl> [newline].” |
[<string>] | “e) “[<string>]” is a regular expression which matches any of the characters in the <string> and no others.” |
[^<string>] | “f) “[^<string>] is a regular expression which matches any character but <nl> [newline] and the characters of the <string>.” |
* | “g) A regular expression followed by “*” is a regular expression which matches any number (including zero) of adjacent occurrences of the text ... |
Get Introducing Regular Expressions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.