[英]How to test the regex to replace 0x1B character (ASCII escape character) in textarea or work notes?
我正在测试一个功能,它可能包含工作备注字段中的ASCII转义字符,我想在将其存储在数据库中之前用空字符串替换所有出现的ASCII转义字符(即我想删除它)。
如何测试0x1b字符?
这是代码片段
<!DOCTYPE html>
<html>
<body>
<h2>Regex to replace 0x1B character (ASCII escape character)</h2>
<button id="btn">Replace</button>
<p id="demo">Be the change that you wish to see in the world. ― Mahatma Gandhi</p>
<script>
var btn = document.getElementById("btn");
btn.onclick = function() {
var str = document.getElementById("demo").innerHTML;
var txt = str.replace(/0x1B/g,'');
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
</html>
请帮我看看如何模拟ASCII转义字符?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.