我想选择以handleSubmit(event) {
event.preventDefault();
let target = event.target;
let formData = {};
for (let i = 0; i < target.length; i++) {
formData[target.elements[i].getAttribute("name")] = target.elements[i].value;
}
console.log('formData', formData);
}
和<h2>
结尾的行,并希望如下所示合并这些行:
现有文本:
</h2>
所需文本:
<h2>
A musician's tattoo
</h2>
If you’ re a musician and would like tolket a tattoo, get a tattoo of your ...
<h2>
A zombie hare chest tattoo
</h2>
100/lO0.002.jpg
You won’ tsee this tattoo every day.
<h2>
Abby Name Tattoos
</h2>
For your little angels, a tattoo of their names will never be a mistake.
我正在使用RegEx <h2> A musician's tattoo </h2>
If you’ re a musician and would like tolket a tattoo, get a tattoo of your ...
<h2> A zombie hare chest tattoo </h2>
100/lO0.002.jpg
You won’ tsee this tattoo every day.
<h2> Abby Name Tattoos </h2>
For your little angels, a tattoo of their names will never be a mistake.
,但只标记了一行。
答案 0 :(得分:0)
(<h2>)\R(.+)\R(.+)
\1\2\3
说明:
(<h2>) : <h2> into group 1
\R : any kind of linebreak
(.+) : matches any character into group 2 (except for line terminators)
\R : any kind of linebreak
(.+) : matches any character into group 3 (except for line terminators)
如果您确实要在H2
文本之前和之后插入空格,则必须在“替换为”中的\2
之前和之后插入空格。对于干净的HTML,这没有任何意义。