O'Reilly logo

Introducing Regular Expressions by Michael Fitzgerald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

FeatureDescription

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required