3 ms·
Do you mean PCRE’s “(?&name)” feature? That is not portable; for instance, Python calls it “(?P=name)”. Or do you mean the common feature of “&” in the replac
by teddyh 2y ago
Do you mean PCRE’s “(?&name)” feature? That is not portable; for instance, Python calls it “(?P=name)”. Or do you mean the common feature of “&” in the replacement string meaning “the whole matched string”? While this feature is common in languages which use regexps (including ed, sed, awk, etc.), that’s not actually a regexp feature, since the & character has that effect in the replacement string, not in the regular expression. It is also not always portable; for instance, Emacs requires escaping as \& for the character to have the special feature.
- dredmorbius 2y agoFrom man(1) less: &pattern Display only lines which match the pattern; lines which do not match the pattern are not displayed. If pattern is empty (if you type & immediately followed by ENTER), any filtering is turned off, and all lines are displayed. While filtering is in effect, an ampersand is displayed at the beginning of the prompt, as a reminder that some lines in the file may be hidden. $ less --version less 487 (GNU regular expressions) Copyright (C) 1984-2016 Mark Nudelman
- teddyh 2y agoOh, you meant the program “less”! Right, I understand what you meant now.
- dredmorbius 2y ago:-) Yeah. I was viewing some files and thinking "it'd be really cool if less(1) had some way of filtering to just lines matching a specific pattern". RTFM'd and TIL'd. Mind that at that point I'd used less for ... oh, at least 30 years.