Regular Expressions 101

Community Patterns

Replace <b> HTML tag with <strong> tag

0

Regular Expression
PCRE (PHP <7.3)

/
<(\/?)b\b((?:[^>"']|"[^"]*"|'[^']*')*)>
/
gm

Description

Replace old formatting HTML tag <b> with semantic <strong> tag. It can be used as a template for replacing any HTML tag, like <i>, etc.

Submitted by O’Reilly Regular Expressions Cookbook - 2 years ago