i had this doubt before and got it cleared here.... this is what i learned....
/m modifier are used to to let $ and ^ match before and after a \n respectively for eg if you do
it would not only match at the beginning but also right after a newline character (ie the second line)...
now for /s modifier it is necessary to know what '.' does usually.
would match foo and bar on different lines...