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 - Linux Tutorial
From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Understand the differences between basic and extended regular expressions3m 38s
-
(Locked)
Matching characters and words with regexes3m 5s
-
(Locked)
Specifying occurrences with regexes1m 56s
-
(Locked)
Alternation and grouping with regexes3m 21s
-
(Locked)
Back references and subexpressions1m 48s
-
(Locked)
Search text using regular expressions5m 31s
-
(Locked)
Use regular expressions to delete, change, and substitute text5m 16s
-
(Locked)
Awareness of Emacs, Nano, and Vim2m 49s
-
(Locked)
An introduction to Vim3m 33s
-
(Locked)
Edit text in Vim2m 45s
-
(Locked)
Search and replace in Vim2m 26s
-
(Locked)
-
-
-
-