Project

General

Profile

Actions

Misc #9801

closed

Regexp documentation for Regexp::EXTENDED is incomplete

Added by allolex (Damon Davison) almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Assignee:
[ruby-core:62327]

Description

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) regexp-extended-whitespace.rb allolex (Damon Davison), 05/03/2014 02:47 PM

Updated by allolex (Damon Davison) almost 10 years ago

I have submitted a pull request on GitHub to make this easier. (Before, I didn't know I could!)

https://github.com/ruby/ruby/pull/606

Updated by zzak (zzak _) almost 10 years ago

  • Status changed from Open to Closed

Fixed by r46096

Actions

Also available in: Atom PDF

Like0
Like0Like0