From: "hsbt (Hiroshi SHIBATA)" <noreply@ruby-lang.org>
To: ruby-dev@ml.ruby-lang.org
Subject: [ruby-dev:52022] [Ruby master Feature#19194] Add Regexp.linear_time?
Date: Tue, 13 Dec 2022 07:03:42 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-100617.20221213070341.9532@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-19194.20221211055433.9532@ruby-lang.org>
Issue #19194 has been updated by hsbt (Hiroshi SHIBATA).
Status changed from Open to Assigned
Assignee set to make_now_just (Hiroya Fujinami)
I added write permission to @make_now_just now. Can you apply this by yourself?
----------------------------------------
Feature #19194: Add Regexp.linear_time?
https://bugs.ruby-lang.org/issues/19194#change-100617
* Author: make_now_just (Hiroya Fujinami)
* Status: Assigned
* Priority: Normal
* Assignee: make_now_just (Hiroya Fujinami)
* Target version: 3.2
----------------------------------------
I suggest adding a new method named `Regexp.linear_time?` to check if matching against a given regexp can be completed in linear time by the optimization introduced in #19104 (GitHub PR [#6486](https://github.com/ruby/ruby/pull/6486)).
This method was discussed in #19104. I'm not sure the name is best.
# Example
```
Regexp.linear_time?(/a/) # => true
Regexp.linear_time?(/(a|a)*\1/) # => false, because this uses a back-reference.
# This can accept a regexp source string and flags like `Regexp.new`.
Regexp.linear_time?('a') # => true
Regexp.linear_time?('a', Regexp::IGNORECASE) # => true
```
For example, this method is useful for implementing a Rubocop rule to check a regexp is ReDoS safe.
# Implementation
Implementation is done at GitHub PR [#6901](https://github.com/ruby/ruby/pull/6901).
See the details there.
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2022-12-13 7:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-11 5:54 [ruby-dev:52014] " make_now_just (Hiroya Fujinami)
2022-12-12 0:56 ` [ruby-dev:52015] " mame (Yusuke Endoh)
2022-12-12 2:05 ` [ruby-dev:52016] " matz (Yukihiro Matsumoto)
2022-12-12 2:06 ` [ruby-dev:52017] " matz (Yukihiro Matsumoto)
2022-12-12 5:40 ` [ruby-dev:52020] " make_now_just (Hiroya Fujinami)
2022-12-13 7:03 ` hsbt (Hiroshi SHIBATA) [this message]
2022-12-13 7:10 ` [ruby-dev:52023] " make_now_just (Hiroya Fujinami)
2022-12-13 7:15 ` [ruby-dev:52024] " hsbt (Hiroshi SHIBATA)
2022-12-14 10:21 ` [ruby-dev:52026] " hsbt (Hiroshi SHIBATA)
2022-12-25 0:06 ` [ruby-dev:52031] " jnchito (Junichi Ito) via ruby-dev
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-100617.20221213070341.9532@ruby-lang.org \
--to=noreply@ruby-lang.org \
--cc=ruby-dev@ml.ruby-lang.org \
/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.
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 NNTP newsgroup(s).