87,921
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#test1,#test2{width:500px;height:200px;border:1px solid #00f;margin-bottom:20px;}
</style>
<script type="text/javascript">
window.onload = function () {
var test1 = document.getElementById('test1'),
test2 = document.getElementById('test2'),
textSource = test1.innerHTML,
textEscape;
var textRegExp = /([A-Za-z\u00C0-\u1FFF\u2800-\uFFFD'\-]+)\s+\1/g;//定义一个重复的单词
textEscape = textSource.replace(textRegExp,"$1");
test2.innerHTML = textEscape;
}
</script>
</head>
<body>
<div id="test1">activity Sizzle It! is is the expert in producing sizzle reels that capture your message and captivate your audience — all with creativity and style. expert sizzle reels that capture</div>
<div id="test2"></div>
</body>
</html>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#test1,#test2{width:500px;height:200px;border:1px solid #00f;margin-bottom:20px;}
</style>
<script type="text/javascript">
window.onload = function () {
var test1 = document.getElementById('test1'),
test2 = document.getElementById('test2'),
textSource = test1.innerHTML,
textEscape;
textSource = textSource.split('').reverse().join('');
var textRegExp = /(\b[A-Za-z\u00C0-\u1FFF\u2800-\uFFFD\'\-]+)(?=\b.*\1)/ig;
textEscape = textSource.replace(textRegExp,"").split('').reverse().join('');
test2.innerHTML = textEscape;
}
</script>
</head>
<body>
<div id="test1">activity Sizzle It! is is the expert in producing sizzle reels that capture your message and captivate your audience — all with creativity and style. expert sizzle reels that capture</div>
<div id="test2"></div>
</body>
</html>
var textRegExp = /\b([A-Za-z\u00C0-\u1FFF\u2800-\uFFFD'\-]+)\b\s+\1/gi; //定义一个重复的单词
textEscape = textSource.replace(textRegExp, "$1");
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#test1,#test2{width:500px;height:200px;border:1px solid #00f;margin-bottom:20px;}
</style>
<script type="text/javascript">
window.onload = function () {
var test1 = document.getElementById('test1'),
test2 = document.getElementById('test2'),
textSource = test1.innerHTML,
textEscape;
var textRegExp = new RegExp((
"(\\w+(?:\\W+\\w+)*)" //单词或单词组成的词组中间用空格或标点隔开
+ "((?:\\W+\\w+)*?)" //重复内容之间的n个单词, 单词之间通过空格或标点隔开
+ "(\\W+)" //重复内容之前的分隔符,比如空格或标点
+ "\\1" //重复内容
), "g");
textEscape = textSource.replace(textRegExp,"$1$2$3");
test2.innerHTML = textEscape;
}
</script>
</head>
<body>
<div id="test1">activity,activity, Sizzle-Sizzle It It! hello world! hello world! activity Sizzle It, activity Sizzle It,</div>
<div id="test2"></div>
</body>
</html>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#test1,#test2{width:500px;height:200px;border:1px solid #00f;margin-bottom:20px;}
</style>
<script type="text/javascript">
window.onload = function () {
var test1 = document.getElementById('test1'),
test2 = document.getElementById('test2'),
textRegExp = /\b([A-Za-z\u00C0-\u1FFF\u2800-\uFFFD\'\-]+)\b(?=.*\b\1\b)/ig,
textSource = test1.innerHTML.split('').reverse().join(''),
textEscape = textSource.replace(textRegExp,"").split('').reverse().join('');
test2.innerHTML = textEscape;
}
</script>
</head>
<body>
<div id="test1">activity Sizzle It! is is the expert in producing sizzle reels that capture your message and captivate your audience — all with creativity and style. expert sizzle reels that capture</div>
<div id="test2"></div>
</body>
</html>