This section contains regular expressions for formatting units of length.
Description
|
Remove commas from quantities of feet or inches. If they're in x'y" format, I'm not worrying about trying to figure out if they represent minutes or seconds of arc because then there couldn't possibly be more than sixty, and so there won't be any commas.
|
Find
|
\b(?<=\d+)(\s| |,)(?=\d{3,3}(?:(?:\s| |,)\d{3,3})*(\.\d*)?(?:\s| |-)*(?:'|’|′|"|”|″|f(?:ee|oo)?t\b|in(?:ch(?:es)?)?\b))
|
Replace with
|
(leave this field blank!)
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15,000'
- 150,000’
- 1,500.8′
- 15,000"
- 150,000”
- 1,500.8″
- 11,000' (3,300 km)
- 5,280 feet
- 1,800 in
|
- 15000'
- 150000’
- 1500.8′
- 15000"
- 150000”
- 1500.8″
- 11000' (3,300 m)
- 5280 feet
- 1800 in
|
Description
|
Replace abbreviated lengths in feet/inches with {{convert}}
|
Find
|
(?<!°(?:\s| )*)(?<!,)\b(\d+)(?:\s| )*(?:ft\b|['’′])(?:\s| )*((?:1[01]|\d)(?:\.\d+)?)(?:\s| )*(?:(?(2)in\b|["”″]))((?:\s| )*\(?\d{1,3}(?:,?\d{3,3})*(\.\d*)?(?:\s| )*(?:k(?:ilo)?|c(?:enti)?)?m(?:eter?|etre?)?s?\b\)?)?
|
Replace with
|
{{convert|$1|ft|$2|in|abbr=on}}
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 6'1"
- 22' 11"
- 105' 8.75"
- 6’1”
- 22′ 11″
- 6'1" (180cm)
- 22' 11" (7.0 m)
- 105' 8.75" (32.2 m)
- 6’1” (1.8m)
- 22′ 11″ (7.0 m)
- 6 ft 1 in
- 22 ft 11 in
|
- 6 ft 1 in (1.85 m)
- 22 ft 11 in (6.99 m)
- 105 ft 8.75 in (32.2263 m)
- 6 ft 1 in (1.85 m)
- 22 ft 11 in (6.99 m)
- 6 ft 1 in (1.85 m)
- 22 ft 11 in (6.99 m)
- 105 ft 8.75 in (32.2263 m)
- 6 ft 1 in (1.85 m)
- 22 ft 11 in (6.99 m)
- 6 ft 1 in (1.85 m)
- 22 ft 11 in (6.99 m)
|
Text this regex should not modify:
|
- 6'13"
- 51° 5' 11" N 0° 7' 9" W
- 51°5'11" N 0°7'9" W
- 51° 5' 11"N 0° 7' 9"W
- 6' 1 in
- 6 ft 1"
|
Description
|
Replace lengths in feet/inches in x' format with {{convert}}
|
Find
|
\b(?<!°(?:\s| )*)(\d+)['’′](\s?\(?\d{1,3}(?:,?\d{3,3})*(\.\d*)?(?:\s| )*(?:k(?:ilo)?|c(?:enti)?)?(?:m(?:eters?|etres?)?)\b)\)?)?(?!(\d+)["”″])
|
Replace with
|
{{convert|$1|ft|abbr=on}}
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 6'
- 22'
- 105'
- 6’
- 22′
- 6' (180cm)
- 22' (7.0 m)
- 105' (32.0 m)
- 6’ (1.8m)
- 22′ (7.0 m)
|
- 6 ft (1.8 m)
- 22 ft (6.7 m)
- 105 ft (32 m)
- 6 ft (1.8 m)
- 22 ft (6.7 m)
- 6 ft (1.8 m)
- 22 ft (6.7 m)
- 105 ft (32 m)
- 6 ft (1.8 m)
- 22 ft (6.7 m)
|
Text this regex should not modify:
|
- 51° 5' 11" N 0° 7' 9" W
- 51°5'11" N 0°7'9" W
- 51° 5' 11"N 0° 7' 9"W
- 6'1"
- 22' 11"
- 105' 8.75"
|
Description
|
Remove commas from quantities of miles.
|
Find
|
\b(?<=\d+)(\s| |,)(?=\d{3,3}(?:(?:\s| |,)\d{3,3})*(\.\d*)?(?:\s| |-)?(?:mi(?:les?)?)\b)
|
Replace with
|
(leave this field blank!)
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15,000 mi
- 150,000 mi
- 1,500.8 miles
- 11,000 miles (20,000 km)
|
- 15000 mi
- 150000 mi
- 1500.8 miles
- 11000 miles (20,000 km)
|
Convert abbreviated noun phrases
edit
Description
|
Replace abbreviated mile noun phrases with {{convert}}.
|
Find
|
\b(?<![,\.$])(\d+(?:\.\d+)?)(?:\s| |-)?mi\b(\s?\(?\d{1,3}(?:,?\d{3,3})*(\.\d*)?(?:\s| )?(?:(?:k(?:ilo)?)?(?:m(?:eters?|etres?)?)\b)\)?)?
|
Replace with
|
{{convert|$1|mi|abbr=on}}
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15-mi
- 15000 mi
- 150000 mi
- 1500.8 mi
- 1 mi
- 11000 mi (20,000 km)
|
- 15 mi (24 km)
- 15,000 mi (24,000 km)
- 150,000 mi (240,000 km)
- 1,500.8 mi (2,415.3 km)
- 11,000 mi (18,000 km)
|
Text this regex should not modify:
|
- 12-mile
|
Convert unabbreviated noun phrases
edit
Description
|
Replace unabbreviated mile noun phrases with {{convert}}.
|
Find
|
\b(?<![,\.$])(\d+(?:\.\d+)?)(?:\s| )?miles?\b(\s?\(?\d{1,3}(?:,?\d{3,3})*(\.\d*)?(?:\s| )?(?:(?:k(?:ilo)?)?(?:m(?:eters?|etres?)?)\b)\)?)?
|
Replace with
|
{{convert|$1|mi}}
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15 miles
- 15000 miles
- 150000 miles
- 1500.8 miles
- 1 mile
- 11000 miles (20,000 km)
|
- 15 miles (24 km)
- 15,000 miles (24,000 km)
- 150,000 miles (240,000 km)
- 1,500.8 miles (2,415.3 km)
- 11,000 miles (18,000 km)
|
Text this regex should not modify:
|
- 12-mile
|
Convert adjectival phrases
edit
Description
|
Replace mile adjectival phrases with {{convert}}.
|
Find
|
\b(?<![,\.$])(\d+(?:\.\d+)?)-miles?\b(\s?\(?\d{1,3}(?:,?\d{3,3})*(\.\d*)?(?:\s| )?(?:\s| )?(?:(?:k(?:ilo)?)?(?:m(?:eters?|etres?)?)\b)\)?)?
|
Replace with
|
{{convert|$1|mi|adj=on}}
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15-mile
- 15000-mile
- 150000-mile
- 1500.8-mile
- 1-mile
- 11000-mile (20,000 km)
|
- 15-mile (24 km)
- 15,000-mile (24,000 km)
- 150,000-mile (240,000 km)
- 1,500.8-mile (2,415.3 km)
- 11,000-mile (18,000 km)
|
Text this regex should not modify:
|
- 12 miles
- 150 mi
|
This task requires three rules. The first strips commas and spaces from large numbers of nautical miles. The second converts standard uses of nautical miles. The third converts adjectival uses of nautical miles. They should not be set up as sub-rules, because then they would only run when we've stripped commas or spaces; we may be dealing with small numbers, so there were no commas to strip, or the article may have simply been written without commas. I don't abbreviate nautical miles, because the symbol to use is disputed, and I feel better writing the unit out than I do using a symbol I don't agree with.
I had originally written just one rule, but I couldn't figure out how to support a number of any length; I had to include separate captures of each group of digits. I set it up to capture the equivalent of a fifth of a light-year, but then I decided that there has to be a way to deal with any number of commas. This is what I came up with.
Description
|
Remove commas from quantities of abbreviated nautical miles. This recognizes "nm" as an abbreviation for nautical miles. Yes, that is the official SI symbol for nanometers. I work primarily on articles about ships, mostly from World War II and before, so I don't run into nanometers very much. I often run into "nm" as an abbreviation for nautical miles. If you see a lot of nanometers, modify this regex, be careful with it, or just don't use it.
|
Find
|
\b(?<=\d+)(\s| |,)(?=\d{3,3}(?:(?:\s| |,)\d{3,3})*(\.\d*)?(?:\s| |-)?(?:nautical(\s| |-)miles?|nmi?)\b)
|
Replace with
|
(leave this field blank!)
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15,000 nm
- 150,000 nmi
- 1,500.8 nm
- 11,000 nm (20,000 km)
|
- 15000 nm
- 150000 nmi
- 1500.8 nm
- 11000 nm (20,000 km)
|
Convert noun phrases
edit
Description
|
Replace nautical mile noun phrases with {{convert}}.
|
Find
|
\b(?<![,\.])(\d+(?:\.\d+)?)(?:\s| )?(?:nautical(\s| |-)miles?|-?nmi?)(\s?\(?\d{1,3}(?:,?\d{3,3})*(\.\d*)?(?:\s| )?(?:kilometers|kilometres|km))?
|
Replace with
|
{{convert|$1|nmi|km}}
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15-nm
- 15000 nm
- 150000 nmi
- 1500.8 nautical miles
- 1 nautical mile
- 11000 nm (20,000 km)
|
- 15 nautical miles (28 km)
- 15,000 nautical miles (28,000 km)
- 150,000 nautical miles (280,000 km)
- 1,500.8 nautical miles (2,779.5 km)
- 11,000 nautical miles (20,000 km)
|
Text this regex should not modify:
|
- 12-nautical-mile
|
Convert adjectival phrases
edit
Description
|
Replace nautical mile adjectival phrases with {{convert}}.
|
Find
|
\b(?<![,\.])(\d+(?:\.\d+)?)-(?:nautical(\s| |-)miles?)(\s?\(?\d{1,3}(?:,?\d{3,3})*(\.\d*)?(?:\s| |-)?(?:kilometers?|kilometres?|km))?
|
Replace with
|
{{convert|$1|nmi|km|adj=on}}
|
Regular expression?
|
Case sensitive?
|
Y
|
N
|
Text this regex should modify:
|
Intended result:
|
- 15-nautical-mile
- 15000-nautical-mile
- 150000-nautical-mile
- 1500.8-nautical-mile
- 1 nautical mile
- 11000-nautical-mile (20,000 km)
|
- 15-nautical-mile (28 km)
- 15,000-nautical-mile (28,000 km)
- 150,000-nautical-mile (280,000 km)
- 1,500.8-nautical-mile (2,779.5 km)
- 11,000-nautical-mile (20,000 km)
|
Text this regex should not modify:
|
- 12 nautical miles
- 150 nm
|