How do I match any character across multiple lines in a regular expression? Try this: ((.|\n)*)<FooBar> It basically says “any character or a newline” repeated zero or more times.