'Test text test text test text cough
word test text test text cough
test text test text test text test text cough
word test text '
The above text test is used to know the position of the first and third cough text and how to change the color of these two words.
<textarea class="editor-input" placeholder="请输入内容" v-model="inputValue"></textarea>
<iframe src="about:blank" id="bbb" contentEditable="true" width="100%" height="100%"></iframe>
Currently using this method to solve
为情所困2017-05-19 10:34:03
The following replaces the first and third coughs, adding red.
var str = '测试文字测试文字测试文咳嗽字测试文字测试文字咳嗽测试文字测试文字测试文字测试文咳嗽字测试文字';
var result = str.replace(/(咳嗽)([^咳]+[^咳]+)/, '<span sytle="color:red"></span><span sytle="color:red"></span>');
console.log(result);
大家讲道理2017-05-19 10:34:03
If you know the location, just subscript and add color. You can also use regular filtering