views:

34

answers:

1

This might not be quite the question you're expecting! I don't want a regex that will match over line-breaks; instead, I want to write a long regex that, for readability, I'd like to split onto multiple lines of code.

Something like:

"bar" =~ /(foo|
           bar)/  # Doesn't work!
# => nil. Would like => 0

Can it be done?

+6  A: 

I think you need to use /x modifier, which enables free-spacing mode.

SilentGhost