test string:
<style>v\:* {behavior:url (#default #vml)} o\:* {behavior:url (#default #vml)} w\:* {behavior:url (#defaul T#VML)}. Shape {behavior:url (#default #vml)} </style> abcdefg <style> @font-face {font-family:wi
Ngdings;
} @font-face {font-family:wingdings;
@font-face {Font-family:calibri} @font-face {font-family:tahoma;
} @page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; } p.msonormal {font-size:12pt;
margin:0in 0in 0pt; Font-family: "Times New Roman", "serif"} LI. MsoNormal {font-size:12pt; margin:0in 0in 0pt; Font-family: "Times New Roman", "serif"} DIV. MsoNormal {font-size:12pt; margin:0in 0in 0pt; Font-family: "Times New Roman", "serif"} H1 {font-weight:bold; font-size:24pt;
margin-left:0in;
margin-right:0in;
Font-family: "Times New Roman", "serif";
Mso-style-priority:9; Mso-style-link: "Heading 1 Char"; Mso-margin-top-alt:auto; Mso-margin-bottom-alt:auto} a:link {COLOR:BLUe Text-decoration:underline; MSO-STYLE-PRIORITY:99} SPAN. Msohyperlink {color:blue; Text-decoration:underline; mso-style-priority:99} a:visited {color:purple; Text-decoration:underline; MSO-STYLE-PRIORITY:99} SPAN. msohyperlinkfollowed {color:purple; Text-decoration:underline; mso-style-priority:99} P {font-size:12pt; margin-left:0in; margin-right:0in;
Font-family: "Times New Roman", "serif"; mso-style-priority:99; Mso-margin-top-alt:auto; Mso-margin-bottom-alt:auto} p.msoacetate {font-size:8pt; margin:0in 0in 0pt;
font-family: "Tahoma", "Sans-serif"; mso-style-priority:99; Mso-style-link: "Balloon Text Char"} LI. msoacetate {font-size:8pt; margin:0in 0in 0pt; font-family: "Tahoma", "Sans-serif"; mso-style-priority:99; Mso-style-link: "Balloon Text Char"} DIV. msoacetate {font-size:8pt; margin:0in 0in 0pt;
font-family: "Tahoma", "Sans-serif"; mso-style-priority:99; Mso-style-link: "Balloon Text Char"} SPAN. Heading1char {font-wEight:bold; Mso-style-priority:9; Mso-style-link: "Heading 1"; Mso-style-name: "Heading 1 Char"} SPAN. EmailStyle19 {COLOR: #1f497d; font-family: "Arial", "Sans-serif"; Mso-style-type:personal-reply} SPAN. Balloontextchar {font-family: "Tahoma", "Sans-serif"; mso-style-priority:99; Mso-style-link: "Balloon Text"; mso-style -name: "Balloon Text Char"}. Msochpdefault {font-size:10pt; mso-style-type:export-only} DIV. WordSection1 {Page:wordsection1} OL {margin-bottom:0in} UL {margin-bottom:0in} </style>
First attempt:<style[^>/]*> (. *?) </style> found that there was no match for line breaks because. is a match for any character except newline (/n).
Second attempt: <style ([\s\s]) *?) </style> success
Matching <div> just need to replace <style> with <div>
1. Replace only the first <style>
var result= testdata.replace (<style ([\s\s]) *?) <\/style> ";
2. Replaces all <style> labels in all testdata
var result= testdata.replace (/<style ([\s\s]) *?) <\/style>/g, "");
G: Delegates can make global matches.
I: represents case-insensitive matching.
M: Represents a multiple-row match.
The above content is small series to introduce JavaScript regular expression matching <div><style> tags, I hope to help!