Regular Expressions 101

reverse commenting/code order

Open Workspace
  • PCRE2 (PHP)
  • Substitution
0

Regular Expression

/
(^\w.*\n\n)+(^(##.*\n)+)
/
gm

Description

reverses order when code is followed by comments (comments prepended with ## )

Submitted by Anonymous