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. var pattern= /<div class="box-content-5">.*<h1>([^<]+?)<\/h1>/mi m = html.search(pattern); return m[1]; I created a string to test it. When the string contains "\n", the result is always null. If I removed all the "\n"s, it gave me the right result, no m
![JavaScript regex multiline text between two tags](https://cdn-ak-scissors.b.st-hatena.com/image/square/98d6f053a97a87156775f60757c60865d0f2c47d/height=288;version=1;width=512/https%3A%2F%2Fcdn.sstatic.net%2FSites%2Fstackoverflow%2FImg%2Fapple-touch-icon%402.png%3Fv%3D73d79a89bded)