The regular expression matches the line-break instance code:
In JavaScript, using regular expressions to match line breaks can be problematic, and here's an example of how to implement this functionality.
<div id= "main" > <div id= "left" > </div > <div id= "right" > Ant tribe Span style= "color: #0000ff;" ></div> </< Span style= "color: #800000;" >div>
If there is no content in the Div, the line is not wrapped
Change the above to read:
<div id= "main" > <div Span style= "color: #ff0000;" >id= "left" ></> <div id= "right" > ant I tribe </div> </div>
JS's positive solution code is as follows:
<ScriptType= "Text/javascript">functionGetv () {VarStr=document.getElementById ("Regtext"). Value;VarRe=/([\n\r]) (\s) * (\<\/DIV\>?) ( \s) *\<div) +/G Str=Str.replace (Re,"$"); alert (str); }</Script><TextAreaId= "Regtext"Cols= "20"Rows= "20"><DivId= "Main"><DivId= "Left"></Div><DivId= "Div1"></Div><DivId= "Div2"></Div><div id= "right" > Ant tribe </div< Span style= "color: #0000ff;" >> </div> Span style= "color: #0000ff;" ></textarea> input type= " Button " Onclick=" Getv () " Value=" test "/>
Regular expression matches line wrap instance code