Regular Expressions 101

Community Patterns

Remove extra/useless python elements for GPT input.

2

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)