js 替換字符串中的字符https://www.w3school.com.cn/jsref/jsref_replace.asp主要替换换行
split() 字符串分割;
function sortArray(array) { array.sort((a, b) => a.length - b.length) return array }
console.log(sortArray(b))
const result = Array.from(new Set(sortArray(e)))
https://yuyp1996.github.io/yyp-demo/dist/#/adaptiveTextarea怎么做文本框
怎么获取文本框中的文字?
code:在F12控制台中使用
var myElements = document.getElementById("eleArea").innerHTML; //获取id为eleArea的dom的字符串
let OutPutWords = myElements.replace(/\n/gi," ").replace(/\t\t/g," ") //替换掉换行回车
OutPutWords.split(" ").sort((a, b) => a.length - b.length)
const uniqueArr = [...new Set(OutPutWords)]
function saveShareContent (content, fileName) {
let downLink = document.createElement('a')
downLink.download = fileName
//字符内容转换为blod地址
let blob = new Blob([content])
downLink.href = URL.createObjectURL(blob)
// 链接插入到页面
document.body.appendChild(downLink)
downLink.click()
// 移除下载链接
document.body.removeChild(downLink)
}
saveShareContent(uniqueArr,20230728)
网友评论