Regular Expressions 101

Community Patterns

Find Comments or Commentblocks in Code

1

Regular Expression
PCRE (PHP <7.3)

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

Description

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

Submitted by Candyman1332 - 8 years ago