我想删除来自用户端的额外空格,但我无法预测 HTML 的格式。
例如:
<p> It's interesting that you would try cfsetting, since nothing in it's
documentation would indicate that it would do what you are asking.
Unless of course you were mis-reading what "enableCFoutputOnly" is
supposed to do.
</p>
<p>
It's interesting that you would try cfsetting, since nothing in it's
documentation would indicate that it would do what you are asking.
Unless of course you were mis-reading what "enableCFoutputOnly" is
supposed to do.</p>
请指导我如何从 HTML 中删除多个空白字符。
最佳答案
您可以使用正则表达式将任何多个空白字符替换为单个空格,方法是循环结果,直到不再出现多个空白:
lastTry = "<p> lots of space </p>";
nextTry = rereplace(lastTry,"\s\s", " ", "all");
while(nextTry != lastTry) {
lastTry = nextTry;
nextTry = REReplace(lastTry,"\s\s", " ", "all");
}
在 CF10 中测试工作。
关于html - 如何从 HTML 中删除多个空白字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12016282/