[ruby-core:94314] [Ruby master Bug#11399] Regexp's free-spacing mode adding whitespace to character classes

From: merch-redmine@...
Date: 2019-08-12 23:35:27 UTC
List: ruby-core #94314
Issue #11399 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Rejected

This is not a bug.  The documentation suggestions the use of character classes if you want to match whitespace (https://docs.ruby-lang.org/en/trunk/regexp_rdoc.html#label-Free-Spacing+Mode+and+Comments).

----------------------------------------
Bug #11399: Regexp's free-spacing mode adding whitespace to character classes
https://bugs.ruby-lang.org/issues/11399#change-80672

* Author: sos4nt (Stefan Sch館ler)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The *free-spacing* mode (x-option) does not ignore whitespace within character classes:

~~~
r = /[a
  # comment
b]/x

" \nab".scan(r)
#=> [" ", "\n", "a", "b"]
~~~

I would expect a regular expression that's equivalent to `/[ab]/`



-- 
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>

In This Thread

Prev Next