Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
[^#]\K#[^\n]*|^#[^\n]*
/
g

Description

This will match the comments. Example:

# hi print "Hello, World!" # hi

will be

[# hi] print "Hello, World!" [# hi]

Submitted by Fmbalbuena - 3 years ago