Regular Expressions 101

Community Patterns

123...7

Remove extra/useless python elements for GPT input.

3

Regular Expression
PCRE2 (PHP >=7.3)

/
((^|\s)#(.*)$)|(^\n)|(\n(\s|)+#(.*)$)|([\n\s]+#.*)|([\n\s]{2,}$)
/
gm

Description

This RegEx removes unused elements such as inline comments and blank lines in python code. This will save you tokens and time when using GPT-3+ or ChatGPT to help code and debug.

Submitted by LukeL - a year ago (Last modified a year ago)