Regexp.new with Multiple Modifier
This may be a no brainer, but I was working with Regexp.new and ran into and wanted to make a regexp with multiple modifiers. It’s easy enough to make one, the docs show you how to:
r = Regexp.new('dog', Regexp::EXTENDED) #=> /dog/xBut what if you want more than one modifier? The docs say they should be “or-ed” together. This is as simple as:
r = Regexp.new('test', Regexp::IGNORECASE | Regexp::MULTILINE)
#=> /test/miYou can even use all three as such:
r = Regexp.new('test', Regexp::IGNORECASE | Regexp::MULTILINE | Regexp::EXTENDED)
#=> /dog/mixSort of a no-brainer once you realize what it means.