Regular Expressions 101

Community Patterns

Get specified open tag

1

Regular Expression
PCRE (PHP <7.3)

/
<(?<tag>\w+)(?:\s+(?<attrs>.*?))?>(?<content>.*)<\/\1>
/

Description

Get open tags with content and attributes

Submitted by Masoud Zohrabi <mdzzohrabi@gmail.com - 9 years ago