我在MySQL列中有一个文本blob字段,其中包含HTML。 我必须更改一些标记,所以我想我会在Ruby脚本中完成它。 这里与Ruby无关,但希望能看到使用Ruby的答案。 标记如下所示:
<h5>foo</h5>
<table>
<tbody>
</tbody>
</table>
<h5>bar</h5>
<table>
<tbody>
</tbody>
</table>
<h5>meow</h5>
<table>
<tbody>
</tbody>
</table>
我需要将每个文本的第一个<h5>foo</h5>
块更改为<h2>something_else</h2>
,同时保留其余部分不变。
使用Ruby似乎无法获得正确的PCRE正则表达式。