Pybot Wiki

This page describes a bit of regex. It must be used within a script or user-fix.

Delete empty sections
Creator: CzechOut
What it does: Removes empty sections from pages
Complexity: Basic

Delete empty sections is a bit of regex that will help you get rid of empty sections on pages. All too frequently people put empty sections into pages, thinking that eventually they'll get filled in. So they might type something like:

== External links ==
''to be added''

But there are many, many pages that will never have external links. This regex scans for a section like this and then deletes it.


python -regex "\=\=( *?)External .*\n''.*''" ""


This regex will match a wide variety of permutations including:

==External links         ===
to be added

== External links==
''to be added''

==External link ==
''coming soon''

==External links==

Known limitations[]

This script does expect for the "to be added" — or equivalent — line to be on the line directly underneath the section head. If there's an additional carriage return, this regex won't match.

This regex also expects a rational use of two equals signs around the section title. It could be easily fixed to check for any number of equal signs with this expression: (\=*?)

Also, because it was the practice that had emerged at w:c:tardis, this script also assumes that the line under the section head will be italicised. The regex could easily be changed to not expect that by simply removing the apostrophes.