Regular Expressions 101

Community Patterns

Match multiline comments /* ... */

2

Regular Expression
PCRE (PHP <7.3)

/
(?<!\/)\/\*((?:(?!\*\/).|\s)*)\*\/
/
g

Description

It won't match single line comments like this one: //* This comment won't be match */ ^ see the double /

Works in PHP without the g modifier.

Submitted by SimonaHalep - 8 years ago