From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Back references and subexpressions

Back references and subexpressions - Linux Tutorial

From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Start my 1-month free trial

Back references and subexpressions

- [Instructor] I've mentioned before that in GNU tools, BREs and EREs are equal. It's interesting to note that in the POSIX standard, EREs do not support back references. If you're using POSIX tools you need to convert these to BREs to get them to work. A back reference is a pattern that's stored in a buffer to be recalled later. We can remember up to nine patters which is the limit. For instance if we wanted to match words that had more than one pair of S's, we'd first create our pattern of double S's and place it in parenthesis so it's remembered. And lastly we'd recall the pattern using a back reference. The format is backslash one, backslash two, and so on up to backslash nine. Note that this regular expression matches with double S's in the parenthesis and then matches again with the back reference. This regular expression would match double s's, followed by any number of characters and then more double s's. We…

Contents