diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-12-29 23:02:19 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-12-30 00:22:32 -0800 |
commit | ff6ee46a283ef023146b4e69fc9cf776ac546899 (patch) | |
tree | e41d1e9648c53db12383eb6742c01cbd1d32a2e4 /doc/regex.texi | |
parent | 575b0ecbad2f34d5777f9562eebc2d0c815bfc5c (diff) | |
download | gnulib-ff6ee46a283ef023146b4e69fc9cf776ac546899.tar.gz |
doc: use “back-reference” for \1 etc.
* doc/regex.texi: Consistently spell “back-reference” with
a hyphen, since that’s how POSIX does it.
Diffstat (limited to 'doc/regex.texi')
-rw-r--r-- | doc/regex.texi | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/doc/regex.texi b/doc/regex.texi index 41a69b10cb..7b83cdd8e1 100644 --- a/doc/regex.texi +++ b/doc/regex.texi @@ -253,7 +253,7 @@ the close-group operator. @cnindex RE_NO_BK_REFS @item RE_NO_BK_REFS If this bit is set, then Regex doesn't recognize @samp{\}@var{digit} as -the back reference operator; if this bit isn't set, then it does. +the back-reference operator; if this bit isn't set, then it does. @cnindex RE_NO_BK_VBAR @item RE_NO_BK_VBAR @@ -1084,11 +1084,11 @@ considers it to match @samp{)}. @node Back-reference Operator @section The Back-reference Operator (@dfn{\}@var{digit}) -@cindex back references +@cindex back-references If the syntax bit @code{RE_NO_BK_REF} isn't set, then Regex recognizes -back references. A back reference matches a specified preceding group. -The back reference operator is represented by @samp{\@var{digit}} +back-references. A back-reference matches a specified preceding group. +The back-reference operator is represented by @samp{\@var{digit}} anywhere after the end of a regular expression's @w{@var{digit}-th} group (@pxref{Grouping Operators}). @@ -1098,13 +1098,13 @@ one of @samp{\1} through @samp{\9} after the corresponding group's close-group operator, you can match a substring identical to the one that the group does. -Back references match according to the following (in all examples below, +Back-references match according to the following (in all examples below, @samp{(} represents the open-group, @samp{)} the close-group, @samp{@{} the open-interval and @samp{@}} the close-interval operator): @itemize @bullet @item -If the group matches a substring, the back reference matches an +If the group matches a substring, the back-reference matches an identical substring. For example, @samp{(a)\1} matches @samp{aa} and @samp{(bana)na\1bo\1} matches @samp{bananabanabobana}. Likewise, @samp{(.*)\1} matches any (newline-free if the syntax bit @@ -1114,7 +1114,7 @@ identical halves; the @samp{(.*)} matches the first half and the @item If the group matches more than once (as it might if followed -by, e.g., a repetition operator), then the back reference matches the +by, e.g., a repetition operator), then the back-reference matches the substring the group @emph{last} matched. For example, @samp{((a*)b)*\1\2} matches @samp{aabababa}; first @w{group 1} (the outer one) matches @samp{aab} and @w{group 2} (the inner one) matches @@ -1125,19 +1125,19 @@ outer one) matches @samp{aab} and @w{group 2} (the inner one) matches @item If the group doesn't participate in a match, i.e., it is part of an alternative not taken or a repetition operator allows zero repetitions -of it, then the back reference makes the whole match fail. For example, +of it, then the back-reference makes the whole match fail. For example, @samp{(one()|two())-and-(three\2|four\3)} matches @samp{one-and-three} and @samp{two-and-four}, but not @samp{one-and-four} or @samp{two-and-three}. For example, if the pattern matches @samp{one-and-}, then its @w{group 2} matches the empty string and its @w{group 3} doesn't participate in the match. So, if it then matches -@samp{four}, then when it tries to back reference @w{group 3}---which it +@samp{four}, then when it tries to back-reference @w{group 3}---which it will attempt to do because @samp{\3} follows the @samp{four}---the match will fail because @w{group 3} didn't participate in the match. @end itemize -You can use a back reference as an argument to a repetition operator. For +You can use a back-reference as an argument to a repetition operator. For example, @samp{(a(b))\2*} matches @samp{a} followed by two or more @samp{b}s. Similarly, @samp{(a(b))\2@{3@}} matches @samp{abbbb}. |