User:TomTheHand/AWB regular expressions

In mid-June, 2006, Bobblewik posted instructions on using his unit and date formatter tools to WP:SHIPS. These tools add easy-to-use tabs to the top of your browser window which provide consistent unit formatting and remove unnecessary date links using regular expressions (regexes). I used them and found them to be very handy in my cleanup of ship history articles.

Recently, I began using AWB, which supports regular expressions. There are small differences between the Javascript regexes used in Bobblewik's tool and the (.NET?) regexes used by AWB, but I read a few tutorials and converted Bobblewik's regexes. Listed below are the regexes that I use in AWB. Bobblewik is the original author for the vast majority of them, though I've tweaked some and rearranged their order a little bit. I've also written a couple myself.

I'm writing this up in order to help AWB users as well as to get advice to improve the regexes I use. My regexes focus primarily on formatting units and adding nbsp's where appropriate. I don't have all of Bobblewik's unit formatter functionality, and I don't have ANY of his date formatter functionality, but I'm adding to it little by little. As I'm very much a beginner with regexes, in some cases I use a simplified version of one of Bobblewik's regexes. My code may therefore have bugs that Bobblewik's does not. I'll take care of these issues little by little. Still, I think what I have now will be useful to AWB users.

A few important notes:
 * Please post questions and comments on the talk page! I'm interested in hearing what people have to say.
 * Copy and paste directly from this page, rather than copying from the page source. I had to use a Wiki trick to get &amp;nbsp; to show up as text instead of a space, and if you copy from the page source you'll copy my trick instead of a regular &amp;nbsp;.
 * I run in case sensitive mode, so some of my regexes look weird because I want specific parts of them to be case insensitive.
 * DOUBLE CHECK the results of these regexes before saving the page! They are far from perfect.

Also, I'd like to say thanks very much to Bobblewik for writing most of these regexes.

Typos
These are basically just simple find-and-replaces for some common mistakes I find. Feel free to use them.

Naval history
One of my interests is naval history. I use the following expressions for formatting naval history articles. They won't be directly useful on other types of articles, but you can use them if you share a similar interest or modify them to serve other purposes.

Above are very simple regexes which add nbsp's between TF, TG, or DesDiv and that force/group/division's number. For example, TF 58, the famous late-WWII Fast Carrier Task Force, gets an nbsp inserted.

Above is a specialized regex used to format the category for destroyers. Many of the ships had their category entries like this: I prefer this: This regex simply looks for ships formatted the first way, and reformats them in the second fashion. You may be able to adapt this to your purposes, but it won't be of any use as-is. I intend to format all destroyer articles this way and then there won't be any more reason to run it!