>> > Ok, let's use "\(.+?\)". >> > >> > You can still get wrong matches with the file names like "abc:123", >> > but perhaps such file names are rare. >> >> Maybe \([A-Za-z]:\| ... >> or something? It is not like there are many Unix file names starting >> with a single letter followed by colon. >> >> But Linux has file names like >> >> /proc/driver/uhci/0000:00:07.2 > > For those files the matching will be fine.
It can't be fine, because the grep output is ambiguous. For example, for the grep output line: 1:2:3:4:text there are three different interpretations: file name `1:2:3', line number `4', source line `text' file name `1:2', line number `3', source line `4:text' file name `1', line number `2', source line `3:4:text' One way to resolve them is to match markup escape sequences that new GNU grep puts around file names and line numbers. You can see them in grep.txt under the title `GNU grep 2.5.1-cvs with default colors'. > The wrong matches occur when the filename contains somewhere the > pattern ":[0-9]+:" or ends with the pattern ":[0-9]+" (like Juri's example) > Juri, wouldn't be good to add a comment about this in grep.el or grep.txt? Since Richard doesn't want to document even `-n' option in grep.el, I am not sure I can add a comment in grep.el about such rare cases with numbers and colons in the file name. -- Juri Linkov http://www.jurta.org/emacs/ _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel