how to set Regexp::MULTILINE enable by default , without change my codes
everywhere ?
can I open Regexp class , and set MULTILINE=true ?
how to set Regexp::MULTILINE enable by default , without change my codes
everywhere ?
can I open Regexp class , and set MULTILINE=true ?
Seems that no. Regexp::MULTILINE have value 4 by default, that means
something for the interpreter. I think setting it to true will break
stuff.
when I write:
a= /xxx/im
b= Regexp.new(“xxx”,Regexp::MULTILINE)
I need set /im and set Regexp::MULTILINE .
how to open Regexp class ,and rewrite Regexp.new ?
example:
#after this , Regexp.new will set Regexp::MULTILINE by default.
class Regexp
alias _initialize initialize
def initialize(a, flag= Regexp::MULTILINE)
_initialize(a, flag && Regexp::MULTILINE )
end
end
[6] pry(main)> Regexp.new ‘s’
=> /s/m
#but /s/ is also /s/ , not /s/m
[7] pry(main)> Regexp.new(‘s’) == /s/
=> false
[8] pry(main)> /s/
=> /s/
class Regexp
alias _initialize initialize if not defined? _initialize
def initialize(a, flag= Regexp::MULTILINE)
_initialize(a, flag && Regexp::MULTILINE )
end
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs