Project

General

Profile

Actions

Bug #8828

closed

regex matching not correct

Added by jjyr (Jinyang Jiang) over 10 years ago. Updated over 10 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.0.0-p247
[ruby-core:56845]

Description

str = " [1]: http://google.com/ "Google""

str =~ /\A\s*[(.+)]:\ (\S+)\s*((?<=").+(?="))/
#=> nil

#then i replace this part '(?<=").+(?=")' with '.+'

str =~ /\A\s*[(.+)]:\ (\S+)\s*(.+)/
#=> 0

$3
#=> ""Google""

$3 =~ /((?<=").+(?="))/
#=> 6

$1

=> "Google"

it can matching now! but i just replace a part of regex with .+, then retry the part, it should not matching? (or it should work at beginning)

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Rejected

Your bug.
Lookbehind matches the preceding part, which matches \s* in your regexp.

Actions

Also available in: Atom PDF

Like0
Like0