Issue #9801 has been reported by Damon Davison.

----------------------------------------
misc #9801: Regexp documentation for Regexp::EXTENDED is incomplete
https://bugs.ruby-lang.org/issues/9801

* Author: Damon Davison
* Status: Open
* Priority: Normal
* Assignee: Zachary Scott
* Category: doc
* Target version: current: 2.2.0
----------------------------------------
The documentation for Regexp::EXTENDED, i.e. the `x` flag says that when it is used, Regexp will ignore all whitespace in the pattern. This is not completely true.

All whitespace is ignored, except for whitespace which has been escaped (`\ `) or is within a character class (`[ ]`). Therefore,

~~~
/this will not do what you mean/x # this will not work as you expect
~~~ 

but 

~~~
/this[ ]will\sdo\ what\s+you\s+mean/x #this will work the same as a pattern without the Regexp::EXTENDED flag
~~~

I found looking at the Perl documentation very useful http://perldoc.perl.org/perlre.html#%2fx

---Files--------------------------------
regexp-extended-whitespace.rb (261 Bytes)


-- 
https://bugs.ruby-lang.org/