This content has been marked as final. Show 2 replies
The MULTILINE flag doesn't change what you can match, it just changes the behavior of the metacharacters, '^' and '$'. Normally, they match only at the beginning and end, respectively, of the input. If the MULTILINE flag is set, they also match the beginning and end (respectively) of any logical line within the input. That is, '^' matches either at the beginning of the input or just after a line separator, and '$' matches either at the end of the input or just before a line separator.
Similarly, the DOTALL flag only affects the behavior of the '.' (dot) metacharacter. Normally, it matches any one character except a line-separator character. If the DOTALL flag is set, the dot matches any character, including line-separator characters. But you don't have to do anything special to match text that includes linefeeds. Except as noted above, '\n' is just another character.
That's great! Thank you.
I wasn't sure but your answer has clarified the use of the MULTILINE flag.