Documentation
¶
Overview ¶
Package regex provides regular expressions for common tasks such as finding and validating email addresses, URLs, and other data formats. It also includes regular expressions for matching specific units of measurement, both imperial and metric.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // URL matches an HTTP or HTTPS address. URL = regexp.MustCompile(`^(https?://)?(?:[^@\n]+@)?([\da-z.-]+)\.([a-z.]{2,6})(:[0-9]+)?([/\w .-]*)*/?(?:[?&#][^\n]*)?$`) // Anchor matches content within an anchor tag. Anchor = regexp.MustCompile(`<a\s([\w =\\":;/.-])*\s*>`) // HourMinutes matches the hour:minutes convention. HourMinutes = regexp.MustCompile(`^\d+:[0-5](\d?){1,2}?`) )
Regular expressions related to HTML.
var BeginsWithWord = regexp.MustCompile(`(?i)^[a-z]+[^\d]`)
BeginsWithWord matches a word at the beginning of a text.
var Decimal = regexp.MustCompile(`\d?\.\d+\b`)
Decimal matches a decimal number.
var Digit = regexp.MustCompile(`(\b\d+\s+\d+/\d+\b)|(\d+\.?/?\d*)`)
Digit matches digits in the text.
var DimensionPattern = regexp.MustCompile(`(\d+)\s*x\s*(\d+).`)
DimensionPattern matches patterns representing dimensions.
var Letters = regexp.MustCompile("[a-zA-Z]+")
Letters matches letters in the text.
var Quantity = regexp.MustCompile(`(?i)\d+\s*((ml|l\b)(°[cf])?|°[cf])`)
Quantity detects quantities, i.e. 1ml, 1 ml, 1l and 1 l.
var RangePattern = regexp.MustCompile(`(\d+(?:/\d+)?)\s*-\s*(\d+(?:/\d+)?)`)
RangePattern matches numerical ranges.
var Time = regexp.MustCompile(`(?i)(\d+\s?h\s*)?(\d+\s?(?:m\b|min|minute|minutter|minuten|timer?)s?\b)|(\d+\s?h\s*)(\d+\s?mins?\b)?|(\d+\s?-\s?\d+\s*timer)`)
Time matches time, such as 1h30min.
var Unit = regexp.MustCompile(`(?i)((?:\d*\.?\d+\s*to\s*)?(?:\d*\s*\d+/)?(?:\d+-\d*/?)?\d*\.?\d+)-?\s*(centimeters?|centimetres?|cm\b|cups?|deciliters?|decilitres?|dl\b|feet|foot|ft\.?\b|′|fluid\s*ounces|fl\.?\s*oz\.*|fluid\s*oz\.?|gallons?|gals?\b|milliliters?|millilitres?|ml\b|millimeters?|millimetres?|mm\b|grams?|grammes?|\d*g\b|inches?|inch|in\b|["”]|kilograms?|kilogrammes?|kg|milligrams?|milligrammes?|mg\b|meters?|metres?|m\b|ounces?|oz\.?|pints?|fl\.?\s*pt\.?|pt\.?|pounds?|lbs?\.?\b|lb\.?\b|#|quarts?|fl\.?\s*qt\.?|qt\.?\b|liters?|litres?|l\b|tablespoons?|ss|tbsp\.?\w*|teaspoons?|ts\w?\.?|tsp\.?\w*|yards?|degrees?\s*celsius|degrees?\s*c|celsius|°?\s?c\b|degrees?\s*fahrenheit|degrees?\s*f|fahrenheit|°?\s?f\b)`)
Unit matches a unit.
var UnitImperial = regexp.MustCompile(`(?i)(cups?|feet|foot|ft\.?\b|′|fluid\s*ounces|fl\.?\s*oz\.*|fluid\s*oz\.?|gallons?|gals?\b|inches?|inch|\d\s?in\b|["”]|ounces?|oz\.?|pints?|fl\.?\s*pt\.?|pt\.?\b|pounds?|lbs?\.?\b|lb\.?\b|#|quarts?|fl\.?\s*qt\.?|qt\.?\b|tablespoons?|tbsp\.?\w*|teaspoons?|tsp\.?\w*|yards?|degrees?\s*fahrenheit|degrees?\s*f|fahrenheit|\b°?f\b)`)
UnitImperial matches an imperial unit.
var UnitMetric = regexp.MustCompile(`(?i)(centimeters?|centimetres?|cm\b|deciliters?|decilitres?|dl\b|millimeters?|millimetres?|mm\b|grams?|grammes?|\b\d*g\b|kilograms?|kilogrammes?|kg|milligrams?|milligrammes?|mg\b|meters?|metres?|\b\d*m\b|milliliters?|millilitres?|ml\b|liters?|litres?|\b\d*l\b|degrees?\s*celsius|degrees?\s*c|celsius|\b°?c\b)`)
UnitMetric matches a metric unit.
var WildcardURL = regexp.MustCompile(`/(cookbooks|recipes|download)/\d+(/\w+(/\d+)?)?$`)
WildcardURL matches a Recipya URL with wildcards.
Functions ¶
This section is empty.
Types ¶
This section is empty.