Regular Expressions 101

r/ProgrammerHumor comment regex

Open Workspace
  • Python
  • Match
0

Regular Expression

r"
(```|`)(python)?\s*?\n?(from \S+ )?import \S+(\n.*?;)*\n((.*return \S+```)|(`return \S+`))
"
gm

Description

A regex that matches comments that adhere to the rules of r/ProgrammerHumor

Submitted by Anonymous