- 正则匹配:.匹配出换行符外的所有字符,/g匹配所有,/m匹配多行
//匹配XML、HTML文档. [.\n]*是匹配不了任意字符的 str.match(/^\s*<[\s\S]+>\s*$/);
- JSON格式化输出:
<html> <body> <pre id="demo"></pre> <script> // json var text = [ {"name":"someone", "age":20, "friends": ["Tom", "Bob"]}, {"name":"somebody", "age":20, "friends": []}, ]; var jsonPretty = JSON.stringify(text, null, 4); document.getElementById('demo').innerHTML = jsonPretty; </script> </body> </html>
[ { "name": "someone", "age": 20, "friends": [ "Tom", "Bob" ] }, { "name": "somebody", "age": 20, "friends": [] } ]
- XML格式化输出:
JavaScript 开发总结(三)
猜你喜欢
转载自www.cnblogs.com/XiongMaoMengNan/p/12327055.html
今日推荐
周排行