Jump to content

User:TomTheHand/Unit tests for AWB regexes/Area and volume

From Wikipedia, the free encyclopedia

This section contains regular expressions for properly formatting units of area and volume.

Replace sq m/km with m² and km²

[edit]
Description
Replace sq km/sq m and variants with km² and m²
Find
sq\.?(?:\s| |-)*(k)?ms?(?!i)
Replace with
$1m²
Regular expression? Case sensitive?
Y Y
Text this regex should modify: Intended result:
  1. sqkm
  2. sq.km
  3. sq km
  4. sq km
  5. sqkms
  6. sq.kms
  7. sq kms
  8. sq kms
  9. sqm
  10. sq.m
  11. sq m
  12. sq m
  13. sqms
  14. sq.ms
  15. sq ms
  16. sq ms
  1. km²
  2. km²
  3. km²
  4. km²
  5. km²
  6. km²
  7. km²
  8. km²
Text this regex should not modify:
  1. sqmi
  2. sq.mi
  3. sq mi
  4. sq mi
  5. sqmis
  6. sq.mis
  7. sq mis
  8. sq mis

Get rid of periods after m² and m³

[edit]
Description
Get rid of periods after m² and m³, if it's definitely not the end of a sentence
Find
m(²|³)\.\)
Replace with
m$1)
Regular expression? Case sensitive?
Y Y
Text this regex should modify: Intended result:
  1. m².)
  2. m³.)
  1. m²)
  2. m³)