I wrote a regex to fetch string from HTML, but it seems the multiline flag doesn\'t work.
This is my pattern and I want to get the text in h1 tag.
h1
You want the s (dotall) modifier, which apparently doesn't exist in Javascript - you can replace . with [\s\S] as suggested by @molf. The m (multiline) modifier makes ^ and $ match lines rather than the whole string.
s
.
m