Board Thread:Support Requests - Getting Technical/@comment-188432-20130624203859

I'm trying to standardise our infoboxes so that newer users can expect them to look pretty much the same. Since we've taken the community stand to disable visual mode, source mode should be as "pretty" and readable as possible. But I can't quite figure out the replacement regex. Imagine that I start with an infobox like this: I want to turn it into this:
 * name=Whatever
 * made before =Whatever
 * made after       = Whatever
 * prev =    Whatever
 * name         = Whatever
 * made before  = Whatever
 * made after   = Whatever
 * prev         = Whatever

Now, obviously the match is pretty straightforward. This works every time: r'( *?)[|]( *?)(.*?)( *?)([=])( *?)(.*?)\n', And if I wanted to put an equal number of spaces between the elements, that's easy, too. The replacement for that works out to: r'|\3\                  \5 \7\n' Easy. But the problem is, that just inserts 20 spaces. Since variable names are of variable length then I haven't really achieved that much. I've still got equals signs all over the place. Yes, I've achieved an equal number of spaces, but it still looks like a mess.

So the regex trick I don't know is this: how do I define in my replacement not 20 spaces but rather the 20th position in the line, so that I can say "put group 5 (the equals sign) at position 20"? 