* [ruby-core:96727] [Ruby master Feature#16491] ruby string scan can not support full regex string feature
[not found] <redmine.issue-16491.20200109073114@ruby-lang.org>
@ 2020-01-09 7:31 ` hakehuang
2020-01-09 7:41 ` [ruby-core:96728] " mame
1 sibling, 0 replies; 2+ messages in thread
From: hakehuang @ 2020-01-09 7:31 UTC (permalink / raw)
To: ruby-core
Issue #16491 has been reported by hakehuang (hake huang).
----------------------------------------
Feature #16491: ruby string scan can not support full regex string feature
https://bugs.ruby-lang.org/issues/16491
* Author: hakehuang (hake huang)
* Status: Open
* 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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:96728] [Ruby master Feature#16491] ruby string scan can not support full regex string feature
[not found] <redmine.issue-16491.20200109073114@ruby-lang.org>
2020-01-09 7:31 ` [ruby-core:96727] [Ruby master Feature#16491] ruby string scan can not support full regex string feature hakehuang
@ 2020-01-09 7:41 ` mame
1 sibling, 0 replies; 2+ messages in thread
From: mame @ 2020-01-09 7:41 UTC (permalink / raw)
To: ruby-core
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-09 7:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-16491.20200109073114@ruby-lang.org>
2020-01-09 7:31 ` [ruby-core:96727] [Ruby master Feature#16491] ruby string scan can not support full regex string feature hakehuang
2020-01-09 7:41 ` [ruby-core:96728] " mame
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 read-only IMAP folder(s) and NNTP newsgroup(s).