-4
考虑以下串串:查找和包裹包含换行符
You look away whilst I weave needles
through my skin to seal the scars,
running repairs, not alterations.
这实际上是存储在数据库为:
You look away whilst I weave needles\r\n
through my skin to seal the scars,\r\n
running repairs, not alterations.\r\n
我怎么会发现,敷在最后两行一个span标签? e.g
You look away whilst I weave needles
<span>through my skin to seal the scars,
running repairs, not alterations.</span>
目前我有:
let regex = new RegExp(stringToMatch,'m'); //I thought 'm', multiline might work?
poem = poem.replace(regex, '<span>' + stringToMatch + '</span>')
的正常工作对于不包含任何\r\n
字符串。