Mark Slagell <ms / iastate.edu> wrote: > >Fung David wrote: > > > > s1 = "abc const const xyz" > > s2 = "abc const\nconst xyz" > > > > re = /abc.*xyz/ > > md = re.match(s1) -> match found > > md = re.match(s2) -> match not found > > > > how can i write the regexp to match s2? > > > > many thanks! > > -david > >Add the /m switch to your regexp specification: > re = /abc.*xyz/m > >Equivalent to: > re = Regexp.new("abc.*xyz",Regexp::MULTILINE) In the same vein: re = /abc(?m:.*)xyz/ turns on the option for just the critical part of the match. I have at least one case where it is useful to know how to do it the latter way. (Currently if you want to modify and recompile an RE the only flag you can capture is case sensitivity. However use that construct and the source specifies the flag.) Cheers, Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com