Regex – How to match any character across multiple lines in a regular expression

multilineregex

For example, this regex

(.*)<FooBar>

will match:

abcde<FooBar>

But how do I get it to match across multiple lines?

abcde
fghij<FooBar>

Best Answer

Try this:

((.|\n)*)<FooBar>

It basically says "any character or a newline" repeated zero or more times.