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

Adding pipe to one element in an infobox
Creator: CzechOut
What it does: adds a pipe to the beginning of a line in an infobox
Complexity: moderate

Adding pipe to one element in an infobox is a bit of regex that will help you fix broken infoboxes. Let's say that you had a prolific editor who was working with templates she had created offline. Unfortunately, one of the variables in the list failed to start with a pipe, meaning that the variable was prevented from being displayed properly in the infobox. And because she's replicated this error hundreds of times across the site, it'll be a pain to manually add this single pipe. This little bit of code searches out the precise line missing a pipe and adds it.

It is typically used with the script.

Code Edit

python -family:tardis_wikia -regex -page:"whatever" 
'\|{1}(.*?)\=(.*?)\n(?!\|)(.*?)' '|\1=\2\n|\3'

Explanation Edit

This regex assumes that your infoboxes are written on your pages in the standard format of:


In other words, this will work so long as each variable is on a new line and the pipe begins that new line.

It assumes, because of the {1}, that there's only one single pipe starting the line. It does not assume a particular number of spaces around the equals sign. Nor does it necessarily assume that the closing curly braces (}}) are on a separate line.

What it does is look for the pattern seen on the variable3 and variable4 lines above, and then insert a prepending pipe before variable4.

Known limitations Edit

Obviously, if your infoboxes aren't set out in this pattern, it won't work at all. For instance, if you've habitually put the pipe at the end of the line rather than the beginning, you'll have to massage this code a bit.

Also, depending on what else you have on your pages, you may need to disqualify a lot more things.

python -page:whatever 
-regex '\|{1}(.*?)\=(.*?)\n(?!\||\}|{|\s|\*|\<)(.*?)' '|\1=\2\n|\3' 

In this example, we're saying that the thing immediately following a new line (\n) should not be any of the following characters:

  • |
  • {
  • }
  • \s (any whitespace character)
  • *
  • <