From: "Mattias Engdegård" <mattiase@acm.org>
To: Michael Welsh Duggan <mwd@md5i.com>
Cc: Richard Copley <rcopley@gmail.com>,
Paul Eggert <eggert@cs.ucla.edu>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: Regexp linting scan
Date: Thu, 5 Dec 2019 12:38:27 +0100 [thread overview]
Message-ID: <D4B2D4D7-F3EE-4A31-AAC2-F308ED8042EE@acm.org> (raw)
In-Reply-To: <877e3bldz4.fsf@md5i.com>
5 dec. 2019 kl. 03.10 skrev Michael Welsh Duggan <mwd@md5i.com>:
>> - "^\\(mailto:\\)\\([^?]+\\)*\\(\\?\\(.*\\)\\)*"
>> + "^\\(mailto:\\)\\([^?]+\\)?\\(\\?\\(.*\\)\\)*"
>
> Wouldn't "^\\(mailto:\\)\\([^?]*\\)\\(\\?\\(.*\\)\\)*" make more sense?
> Maybe even without the grouping, as it doesn't seem to be used. If I'm
> not mistaken (and I might be) this matches "mailto:" followed by anything
> as long as it contains at most one question mark.
Group 2 is actually used (see rfc2368-mailto-prequery-index). Although your suggested change does not alter the set of matched strings, the code would need to be altered as well, since group 2 would then be the empty string instead of nil when it did not match anything.
(The group around mailto: is harder to justify.)
>> - (while (verilog-re-search-forward-quick "\\.\\s *\\([a-zA-Z0-9`_$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t)
>> + (while (verilog-re-search-forward-quick "\\.\\s *\\([a-zA-Z0-9`_$]+\\)?\\s *(\\s *\\1\\s *)\\s *" end-pt t)
>
> Similarly, in this one I think you could also replace the `+' with a `*'
> and leave out the `?'.
Group 1 is used in a backref, which only matches if the group matched. With your change, the regexp would match ".()", which isn't matched at present.
The repetition-of-repetition check does not complain about \(X+\)? for these reasons. It is also not a performance concern.
next prev parent reply other threads:[~2019-12-05 11:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-01 22:20 Regexp linting scan Mattias Engdegård
2019-12-02 10:14 ` Richard Copley
2019-12-02 10:19 ` Mattias Engdegård
2019-12-05 0:57 ` Paul Eggert
2019-12-05 2:10 ` Michael Welsh Duggan
2019-12-05 11:38 ` Mattias Engdegård [this message]
2019-12-05 12:11 ` Mattias Engdegård
2019-12-06 3:34 ` Paul Eggert
2019-12-05 10:21 ` Mattias Engdegård
-- strict thread matches above, loose matches on Subject: below --
2020-01-30 16:16 Mattias Engdegård
2020-02-20 15:13 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D4B2D4D7-F3EE-4A31-AAC2-F308ED8042EE@acm.org \
--to=mattiase@acm.org \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=mwd@md5i.com \
--cc=rcopley@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).