Regular Expressions 101

Community Patterns

Find comments or commentblocks in Code V1.01

-1

Regular Expression
PCRE (PHP <7.3)

/
((?<raute>#(?<raute_content>[^\n]*))|(?<doubleslashes>\/\/(?<doubleslashes_content>[^\n]*))|(?<block>\/\*(?<block_content>[^*]+|\*(?!\/))*+\*\/))
/
gm

Description

Find Comments starting with # or //. Also finds Commentblocks starting with /* and ending with */.

Submitted by Candyman1332 - 8 years ago