Untitled

mail@pastecode.io avatar
unknown
javascript
10 days ago
4.0 kB
2
Indexable
Never
  var SI_Prefixes_Abbreviated = "d|c|m|u|n|p|f|a|z|y" + "|da|h|k|M|G|T|P|E|Z|Y";
  var SI_Prefixes =
    "deci|ceni|milli|micro|nano|pico|femto|atto|zepto|yocto" +
    "|deca|hecto|kilo|mega|giga|tera|peta|exa|zetta|yotta";

  var SI_Lengths_Abbreviated = "m";
  var SI_Lengths = "meters|meter";
  var Other_Lengths =
    "inch|in|ft|foot|yd|yard|mile|mi|li|link|rd|rod|ch|chain|angstrom|mil";

  var SI_Areas_Abbreviated = "m2";
  var Other_Areas = "sqin|sqft|sqyd|sqmi|sqch|sqmil|acre|hectare";

  var SI_Volumes_Abbreviated = "m3|l|L";
  var SI_Volumes = "litre|liter";
  var Other_Volumes = "cc|cuin|cuft|cuyd|teaspoon|tablespoon";
  var Other_Liquid_Volumes =
    "minim|fluiddram|fldr|fluidounce|floz|gi|gill|cup|cp|pt|pint|qt|quart|gal|gallon|bbl|beerbarrel|obl|oilbarrel|hogshead|gtt|drop";

  var SI_Time_Abbreviated = "s";
  var SI_Time = "second|seconds|secs";
  var Other_Time =
    "minute|mins|minutes|hours|hour|hrs|hr|h|days|day|weeks|week|months|month|years|year|decades|decade|centuries|century|millennia|millennium";

  var Other_Angles =
    "°|radians|radian|rad|degrees|degree|deg|gradians|gradian|grad|cycles|cycle|arcseconds|arcsecond|arcsec|arcminutes|arcminute|arcmin";

  var SI_Frequency_Abbreviated = "Hz";
  var SI_Frequency = "hertz";

  var SI_Mass_Abbreviated = "g";
  var SI_Mass = "gram|grams";
  var Other_Mass =
    "tonnes|tonnes|tons|ton|grains|grain|gr|drams|dram|dr|ounces|ounce|oz|poundmasses|poundmass|lbm|lb|lbs|hundredweights|hundredweight|cwt|sticks|stone";

  var SI_Current_Abbreviated = "A";
  var SI_Current = "ampere|amperes";

  var Other_Tempatures =
    "kelvin|K|celsius|degC|fahrenheit|degF|rankine|degR|°C|°F|°R";

  var SI_Amount_Of_Substance_Abbreviated = "mol";
  var SI_Amount_Of_Substance = "mole|moles";

  var SI_Luminous_Intensity_Abbreviated = "cd";
  var SI_Luminous_Intensity = "candela";

  var SI_Force_Abbreviated = "N";
  var SI_Force = "newton";
  var Other_Force = "dyne|dyn|poundforce|lbf|kips|kip";

  var SI_Energy_Abbreviated = "J|wH|eV";
  var SI_Energy = "joules|joule|electronvolts|electronvolt";
  var Other_Energy = "erg|BTUs|BTU";

  var SI_Power_Abbreviated = "W";
  var SI_Power = "watts|watt";
  var Other_Power = "hp";

  var SI_Pressure_Abbreviated = "Pa";
  var Other_Pressure = "psi|atm|torr|bar|mmHg|mmH2O|cmH2O";

  var SI_Electricty_Abbreviated = "A|C|V|F|Wb|T|H|S";
  var SI_Electricity =
    "amperes|ampere|amps|amp|coulombs|coulomb|volts|volt|ohms|ohm|farads|farad|webers|weber|teslas|tesla|henry|siemens";

  var SI_Binary_Abbreviated = "b|B";
  var SI_Binary = "bits|bit|bytes|byte";

  var digitBoundary = `(?<=\\b\\d*)`; // Allows digits to be next to the unit, but not other letters

  var Non_Word_Char_Units = "°(C|F|R)?";

  var Unit_Regex =
    // Non-word characters and other lengths with no prefixes
    `${Non_Word_Char_Units}|(${digitBoundary}(${Other_Lengths}|${Other_Areas}|${Other_Volumes}|${Other_Liquid_Volumes}|${Other_Time}|${Other_Angles}|${Other_Mass}|${Other_Tempatures}|${Other_Force}|${Other_Energy}|${Other_Power}|${Other_Pressure})${digitBoundary}` +
    `|${digitBoundary}(${SI_Prefixes_Abbreviated})?(` +
    // Abbreviated SI Units with abbreviated SI prefixes
    `${SI_Lengths_Abbreviated}|${SI_Areas_Abbreviated}|${SI_Volumes_Abbreviated}|${SI_Time_Abbreviated}|${SI_Mass_Abbreviated}|${SI_Frequency_Abbreviated}|${SI_Current_Abbreviated}|${SI_Amount_Of_Substance_Abbreviated}|${SI_Luminous_Intensity_Abbreviated}|${SI_Force_Abbreviated}|${SI_Energy_Abbreviated}|${SI_Power_Abbreviated}|${SI_Pressure_Abbreviated}|${SI_Electricty_Abbreviated}|${SI_Binary_Abbreviated})\\b` +
    `|${digitBoundary}(${SI_Prefixes})?(` +
    // SI Units with SI prefixed
    `${SI_Lengths}|${SI_Time}|${SI_Mass}|${SI_Frequency}|${SI_Current}|${SI_Volumes}|${SI_Luminous_Intensity}|${SI_Amount_Of_Substance}|${SI_Force}|${SI_Energy}|${SI_Power}|${SI_Electricity}|${SI_Binary}` +
    `)${digitBoundary})`;
Leave a Comment