Home
Web Front-end
JS Tutorial
Solve js regular matching line break problem implementation code_Basic knowledge



Solve js regular matching line break problem implementation code_Basic knowledge
May 16, 2016 pm 05:47 PM
match
newline
Copy code The code is as follows:
<div id="main">
<div id=”left”>
</div>
<div id=”right”>
php
</div>
</ div> >
The code is as follows:
<div id="main">
<div id="left"></div>
<div id="right"> php </div> </div> If you use JS to write it, how should you write it?
The correct code for JS is as follows: HTML code:
Copy code
The code is as follows: Copy code
<script type="text/javascript">
function getV(){
var str=document.getElementById("regtext").value; var re=/([nr ])(s)*(</div>?(s)*<div) /g; str=str.replace(re,"$3"); alert(str); } </script> <textarea id="regtext" cols="20" rows="20">
<div id="main"> < ;div id="left">
</div>
<div id="Div1">
</div>
<div id="Div2"> ;
</div>
<div id="right">
php
</div>
</div>
</textarea>
<input type="button" onclick="getV()" value="Test" />
</div>
<div id="Div1">
</div>
<div id="Div2"> ;
</div>
<div id="right">
php
</div>
</div>
</textarea>
<input type="button" onclick="getV()" value="Test" />
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Practical Guide to Regular Expressions in Go: How to Match Hexadecimal Color Codes

PHP regular expressions: exact matching and exclusion of fuzzy inclusions

How to wrap lines in BarTender - How to wrap lines in BarTender

PHP regular expression in action: matching letters and numbers

How to wrap cells in Excel on Apple computers

How to wrap line on iPhone? How to set line wrap on iPhone?

PHP String Matching Tips: Avoid Ambiguous Included Expressions
