考虑以下输入作为一个例子:
[Ami]Song lyrics herp derp [F]song lyrics continue
[C7/B]Song lyrics continue on another [F#mi7/D]line
我需要解析上述内容,并将其作为以下内容输出:<div class="chord">Ami</div>Song lyrics herp derp <div class="chord">F</div>song lyrics continue
<div class="chord">C7/B</div>Song lyrics continue on another <div class="chord">F#mi7/D</div>line
基本上,我需要:
1)将 [
更改为 <div class="chord">
,
2)然后附加括号内的内容,
3)最后将 ]
更改为 </div>
。
... 使用 PHP 5.3+。