1. Replace all <b> with <strong>, preserving any existing attributes
Match:
<(/?)b\b((?:[^>"']| "[^"]*"| '[^']*')*)>
Replace:
<\1strong\2>
eg.
<b fdjfkjdk>inikkk</b fdjkfjk>
====>
<strong fdjfkjdk>inikkk</strong fdjkfjk>
2. Replace all <b> with <strong>, discarding any existing attributes
Match:
<(/?)b\b((?:[^>"']| "[^"]*"| '[^']*')*)>
Replace:
<\1strong\2>
eg.
<b fdjfkjdk>inikkk</b fdjkfjk>
====>
<strong>inikkk</strong>
3. Replace a list of tags (<b> <i> <em> <big>) with <strong>, preserving any existing attributes
Match:
<(/?)([bi]|em|big)\b((?:[^>"']| "[^"]*"| '[^']*')*)>
Replace:
<\1strong\3>
eg.
<b fdjfkjdk>inikkk</b fdjkfjk>
<i fff>nihao</i nihao>
<em ff>nihao</em nihao>
<big ff>nihao</big nihao>
=====>
<strong fdjfkjdk>inikkk</strong fdjkfjk>
<strong fff>nihao</strong nihao>
<strong ff>nihao</strong nihao>
<strong ff>nihao</strong nihao>
4. Replace a list of tags (<b> <i> <em> <big>) with <strong>, discarding any existing attributes
Match:
<(/?)([bi]|em|big)\b((?:[^>"']| "[^"]*"| '[^']*')*)>
Replace:
<\1strong>
eg.
<b fdjfkjdk>inikkk</b fdjkfjk>
<i fff>nihao</i nihao>
<em ff>nihao</em nihao>
<big ff>nihao</big nihao>
=====>
<strong>inikkk</strong>
<strong>nihao</strong>
<strong>nihao</strong>
<strong>nihao</strong>
Python 正则表达式替换所有的<b>为<strong>
最新推荐文章于 2024-04-03 15:39:01 发布