简体   繁体   English

我们如何在正则表达式中替换 span contenteditable?

[英]how can we replace span contenteditable in regex?

let qs='<span contenteditable="true">sssss</span>'

i want to replace span to sssss.我想将跨度替换为 sssss。

after replacing word should look like +++sssss+++替换单词后应该看起来像 +++sssss+++

Use regex /<span.*>(.*)<\\/span>/g and string replace (or replaceAll) with captured group.使用正则表达式/<span.*>(.*)<\\/span>/g和字符串替换(或replaceAll)与捕获的组。

qs.replace(/<span.*>(.*)<\/span>/g, '+++$1+++')

 const regex = /<span.*>(.*)<\\/span>/g; let qs='<span contenteditable="true">sssss</span>'; const newQs = qs.replace(regex, '+++$1+++'); console.log(newQs);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在跨度中将输入的文本包装在可内容编辑的元素中? - How can I wrap inputted text in a contenteditable elememt in a span? React Contenteditable - 如何将 onClick 分配给<span>react-contenteditable?</span> - React Contenteditable - how can I assign an onClick to a <span> in react-contenteditable? 我们如何仅在 JavaScript 中将特定的 span 标签替换为特定的 label 标签 - how we can replace particular span tag to particular label tag in JavaScript only 我怎样才能更换一个<blockquote><span>与jquery?</span> - How can i replace a <blockquote> with a <span> with jquery? 如何防止使用 contenteditable 删除跨度内? - How to prevent remove inside span using contenteditable? 如何在glyphicon点击上突出显示contentEditable span - How to highlight a contentEditable span on glyphicon click 如何将光标移动到 ContentEditable Span 的开头/结尾 - How to move cursor to beginning/end of ContentEditable Span 如何在内容可编辑范围内设置光标位置 - How to set cursor position in contenteditable span 如何在contenteditable div中的跨度中设置光标位置 - How to set cursor position in span in contenteditable div 如何在contentedable span中设置插入位置然后发送Keys? - How to set caret position in contenteditable span and then sendKeys?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM