dojo/date/locale::regexp()

Builds the regular expression needed to parse a localized date. This is mainly designed as an internal function but is exposed if needed. It defaults to using the current locale and the default formatting options to generate the regular expression but can be controlled using for the formatting options just like other functions in the module.

Usage

require(["dojo/date/locale"], function(locale){
  // Return a regular expression based on the defaults for the current locale
  var exp = locale.regexp();

  // Return the short date regular expression for "en-gb" locale
  var exp = locale.regexp({
    formatLength: "short",
    selector: "date",
    locale: "en-gb"
  });
});

Attributes

Arguments Type Description
options dojo/date/locale::__FormatOptions? Optional Uses the format options to generate the string see: format()

The function returns a String.

require(["dojo/date/locale", "dojo/dom", "dojo/domReady!"],
function(locale, dom){
  var output = locale.regexp({
    formatLength: "short",
    selector: "date",
    locale: "en-gb"
  });
  dom.byId("output").innerHTML = output;
});
<strong>Output:</strong>
<pre id="output"></pre>
Error in the documentation? Can’t find what you are looking for? Let us know!