0

I'm trying to catch a text start with a string and ends with string, but the problem the match regular expression stop at the newline.

I would like to catch all text including newlines from "StartFragment" to "EndFragment"

<body lang=RU style='tab-interval:35.4pt'> <!--StartFragment--><span lang=EN-US style='font-size:11.0pt;line-height: 107%;font-family:"Calibri",sans-serif;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi; mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA'>Sdfsd </span><u><span lang=EN-US style='font-size:18.0pt;line-height:107%;font-family: "Calibri",sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family: Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi; color:red;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language: AR-SA'>sfsdfsfsdfsdf </span></u><b style='mso-bidi-font-weight:normal'><span lang=EN-US style='font-size:8.0pt;line-height:107%;font-family:"Calibri",sans-serif; mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font: minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language: EN-US;mso-bidi-language:AR-SA'>sdsdfsdfsdfsd</span></b><!--EndFragment--> </body>

I'm using the next regular expression but because of the newlines its not catching all text:

/<!--StartFragment-->.+<!--EndFragment-->/mi
user2678018
  • 331
  • 2
  • 3
  • 10
  • it dosent seem to work, please look: https://regex101.com/r/gI5yM9/1 – user2678018 Sep 25 '16 at 08:06
  • `.` does not match newline. Instead, use `[\s\S]`, or `[^]`. –  Sep 25 '16 at 08:10
  • This is not a duplicate of the "muliline flag" question, which is about matching the beginning and ends of lines with anchors. It is about how to match newlines themselves inside strings (the second duplicate shown at the top of the page). –  Sep 25 '16 at 08:12

0 Answers0