Project

General

Profile

Actions

Bug #11399

closed

Regexp's free-spacing mode adding whitespace to character classes

Added by sos4nt (Stefan Schüßler) over 8 years ago. Updated over 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:70148]

Description

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

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • 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).

Actions

Also available in: Atom PDF

Like0
Like0