在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java  HTML/ nodejs 如何刷選出文本中的所有中文?將一個(gè)html頁(yè)面或者js文本的所有中

nodejs 如何刷選出文本中的所有中文?將一個(gè)html頁(yè)面或者js文本的所有中文提取出來(lái)(并且去掉所有注釋文本)?

nodejs 如何刷選出文本中的所有中文?將一個(gè)html頁(yè)面或者js文本的所有中文提取出來(lái)(保留中文之間的任意字符,并且去掉所有注釋文本),放到另外一個(gè)文本?

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>首頁(yè)-我是一個(gè)可愛的小蘿莉</title>
</head>

<body>
    <div id="div1">我是一個(gè)div,并且id='div1'</div>
    <div id="div2">我也是一個(gè)div,div2, 《書名=“嘻嘻嘻”》</div>
    <div class="hidden">
        你一定能看到我的
        <!-- 這里的我,你是看不到的啦 -->
    </div>
    <script type="text/javascript">
        // var getId = function(id) {
        //  return document.getElementById(id)
        // }
        /*這里是測(cè)試內(nèi)容,真的!!*/
        document.getElementById = (function (func) {
            return function () {
                return func.apply(document, arguments)
            }
        })(document.getElementById)
        var getId = document.getElementById;
        console.log(getId('div1'))

        /*      var func = function(a, b, c) {
          'use strict';
          console.log(this)
          console.log(this === window)
        }
        func.apply(null, [1,2,3])*/

        /*  document.getElementById('div1').onclick = function() {
            var func =function() {
              console.log(this.id)
            }
            func.call(this)
          }*/


        Function.prototype.bind = function (context) {
            /*  var self = this;
              return function() {
                return self.apply(context, arguments)
              }*/

            var self = this,
                context = [].shift.call(arguments), // 提取出上下文
                args = [].slice.call(arguments); // 剩余參數(shù)轉(zhuǎn)為數(shù)組

            console.log(context, arguments, args)
            return function () {
                // 結(jié)合兩次的參數(shù)
                return self.apply(context, [].concat.call(args, [].slice.call(arguments)))
            }
        }

        var obj = {
            name: 'sven'
        }

        var func = function (a, b, c, d) {
            console.log(this.name)
            console.log([a, b, c, d])
        }.bind(obj, 1, 2)
        func(3, 4)

        /**
         * 歡迎大家加入我們的大家庭,你也看不到我的
         *
         * @param {*} [params=[]]
         */
        function HelloWord(params = []) {
            console.log('歡迎來(lái)到中國(guó)的大家庭:', ...params)
        }
    </script>
</body>

</html>
回答
編輯回答
過客

不太明白你想獲取中文是什么需求。如果你是想獲取標(biāo)簽內(nèi)的文本 你可以用cheerio。 真要獲取中文你可以全轉(zhuǎn)成Unicode 然后判斷中文范圍。去掉注釋的話 還是要靠正則=-=.

2017年10月11日 20:16