[ruby-core:96728] [Ruby master Feature#16491] ruby string scan can not support full regex string feature
From:
mame@...
Date:
2020-01-09 07:41:33 UTC
List:
ruby-core #96728
Issue #16491 has been updated by mame (Yusuke Endoh). Status changed from Open to Rejected Try this regex: ``` /<testsuites(?:(?!<\/testsuites>).|\n)+<\/testsuites>/m ``` `String#scan` returns an array of whole matched strings if the regex has no capture, but it returns captured strings (`$1`, `$2`, ...) if the regex captures them. Your regex uses `(...)` which is a capture. Instead, you may want to use `(?:...)` which does not capture a string. ---------------------------------------- Feature #16491: ruby string scan can not support full regex string feature https://bugs.ruby-lang.org/issues/16491#change-83717 * Author: hakehuang (hake huang) * Status: Rejected * Priority: Normal * Assignee: * Target version: ---------------------------------------- I have a complex regex string which works fine with match method, but fails with scan. and I think it is because the scan method does not implement full function link match. please see attached test file. the test match regex is /<testsuites((?!<\/testsuites>).|\n)+<\/testsuites>/m ---Files-------------------------------- test.rb (1.9 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>