>From 3e22ab3552fc2ebde6b99ceb2e46700bdbc55072 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 30 Dec 2019 10:41:43 -0800 Subject: [PATCH] =?UTF-8?q?doc:=20don=E2=80=99t=20encourage=20back-referen?= =?UTF-8?q?ces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/grep.texi (Usage): Remove palindrome question. Bondioni’s RE makes grep issue a ‘grep: stack overflow’ diagnostic, and we shouldn’t be encouraging fancy back-references anyway, due to all the bugs in this area (Bug#26864). Plus, the allusion to “GNU extensions” doesn't seem to be correct here. --- doc/grep.texi | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/doc/grep.texi b/doc/grep.texi index aceaf33..7c2b865 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -1800,31 +1800,6 @@ Use the special file name @samp{-}: cat /etc/passwd | grep 'alain' - /etc/motd @end example -@item -@cindex palindromes -How to express palindromes in a regular expression? - -It can be done by using back-references; -for example, -a palindrome of 4 characters can be written with a BRE: - -@example -grep -w -e '\(.\)\(.\).\2\1' file -@end example - -It matches the word ``radar'' or ``civic.'' - -Guglielmo Bondioni proposed a single RE -that finds all palindromes up to 19 characters long -using @w{9 subexpressions} and @w{9 back-references}: - -@smallexample -grep -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file -@end smallexample - -Note this is done by using GNU ERE extensions; -it might not be portable to other implementations of @command{grep}. - @item Why is this back-reference failing? -- 2.17.1