中文内容如下有重复文字,在下图中输入内容文字,点击统计去除了重复文字并显示无重复内容要怎么实现

中文内容如下有重复文字,在下图中输入内容文字,点击统计去除了重复文字并显示无重复内容要怎么实现?

如内容:有你就是幸福的你是我今生最幸福的人

img

怎么样增加重复次数,比如:
你今天好吗?
我今天很好
我今天不好
这三句话中,《我》重复了2次,《今天》和《好》重复了三次,无重复结果要显示2次重复的结果跟最多的统计结果,比如要显示《我》重复了2次,《今天》《好》重复了3次?

重复1次:你吗很不
重复2次:我
重复3次:今天好

img

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>输入去重内容</div>
  <textarea name="" id="text" cols="30" rows="10"></textarea>
  <button onclick="handler()">统计</button>
  <div>无重复结果</div>
  <div id="result"></div>
  <script>
    function handler(){
      const value = document.getElementById('text').value;
      document.getElementById('result').innerHTML = [...new Set(value)].join('');
    }
  </script>
</body>
</html>

这样?

这样?

img

<html>
<head>
<script src="jquery-1.8.1.js"></script>
<SCRIPT LANGUAGE="JavaScript">
$(function(){
 $('#delRepeat').click(function(){
  var str = $('#repeatValue').val();
     var reg = /(.)(?=.*\1)/g;//预搜索方式(有的叫断言)
     var result = str.replace(reg, "");
     $('#noRepeat').val(result);
 })
})
</SCRIPT>
</head>
<body>
原值<input id="repeatValue" type="text" value="aca" ><input id="delRepeat" type="button" value="统计">
<input type="text" id="noRepeat">
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>输入去重内容:</p>
    <input id="input" />

    </input>
    <button id="btn">统计</button>
    <p>无重复结果:</p>
    <p id="res"></p>
</body>
<script>
    var val = document.getElementById('input')
    var btn = document.getElementById('btn')
    var res = document.getElementById('res')
    btn.addEventListener('click', function () {
        if (!val.value) return
        res.innerHTML = Array.from(new Set(val.value.split(''))).join('')
    })
</script>
</html>

有你就是幸福的你是我今生最幸福的人

img

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>输入去重内容:</p>
    <input id="input" />
 
    </input>
    <button id="btn">统计</button>
    <p>无重复结果:</p>
    <p id="res"></p>
    <p>重复次数:</p>
    <p id="repeatRes"></p>
</body>
<script>
    var val = document.getElementById('input')
    var btn = document.getElementById('btn')
    var res = document.getElementById('res')
    btn.addEventListener('click', function () {
        if (!val.value) return
        var initList = [...val.value.split('')]
        var valList = [...new Set(initList)]
        res.innerHTML = valList.join('')
        var list = []
        valList.forEach(i => {
            list.push(initList.filter(t => t === i))
        })
        var mlist = [];
        list.forEach((i, index) => {
            mlist.push({
                name: valList[index],
                num: i.length,
            })
        })
        var resList = mlist.filter(i => i.num > 1)
        console.log(resList) 
        var repeatRes = document.getElementById("repeatRes")
        var innerHTML = ''
        resList.forEach(i => {
            innerHTML += `
                【${i.name}】重复了${i.num}次;
            `
        })
        repeatRes.innerHTML = innerHTML
    })
</script>
</html>