Regular Expressions 101

Community Patterns

1...45678...901

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
<?[^<>]*>|<[^>]*
/
g

Description

Strip all HTML tags from a string. HTML tags are enclosed in < and >.

The regex will be applied on a line-by-line basis, meaning partial tags will need to be handled by the regex. Don't worry about opening or closing tags; we just want to get rid of them all.

Note: This task is meant to be a learning exercise, and not necessarily the best way to parse HTML

Submitted by anonymous - 2 months ago