JavaScript regex multiline flag doesn't work

前端 未结 5 1768
清酒与你
清酒与你 2020-11-22 09:41

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.

5条回答
  •  感动是毒
    2020-11-22 10:11

    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.

提交回复
热议问题