Project

General

Profile

Actions

Bug #9728

closed

Regexp bug

Added by sawa (Tsuyoshi Sawada) almost 10 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Ruby 2.0
[ruby-core:61959]

Description

As reported in StackOverflow (http://stackoverflow.com/questions/23004527) (with a wrong expectation), the following regex pattern with the * operator does not match.

"ab" =~ /(?!^a).*b/
# => nil

When ? is used instead, it seems to match correctly:

"ab" =~ /(?!^a).?b/
# => 1

According to the original reporter of the linked site, this does not happen in Ruby 1.9.3.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0