Method: Regexp.timeout=
- Defined in:
- re.c
.timeout=(float) ⇒ Object
It sets the default timeout interval for Regexp matching in second. nil
means no default timeout configuration. This configuration is process-global. If you want to set timeout for each Regexp, use timeout
keyword for Regexp.new
.
Regexp.timeout = 1
/^a*b?a*$/ =~ "a" * 100000 + "x" #=> regexp match timeout (RuntimeError)
4725 4726 4727 4728 4729 4730 4731 4732 4733 |
# File 're.c', line 4725
static VALUE
rb_reg_s_timeout_set(VALUE dummy, VALUE timeout)
{
rb_ractor_ensure_main_ractor("can not access Regexp.timeout from non-main Ractors");
set_timeout(&rb_reg_match_time_limit, timeout);
return timeout;
}
|