dojox/validate/regexp (version 1.10)

See the dojox/validate/regexp reference documentation for more information.

Property Summary

Method Summary

  • emailAddress(flags) Builds a regular expression that matches an email address
  • emailAddressList(flags) Builds a regular expression that matches a list of email addresses.
  • host(flags) Builds a RE that matches a host
  • ipAddress(flags) Builds a RE that matches an IP Address
  • numberFormat(flags) Builds a regular expression to match any sort of number based format
  • url(flags) Builds a regular expression that matches a URL

Properties

ca
Defined by: dojox/validate/regexp
us
Defined by: dojox/validate/regexp

Methods

emailAddress(flags)

Builds a regular expression that matches an email address

Parameter Type Description
flags Object
Optional
  • flags.allowCruft Allow address like <mailto:foo@yahoo.com>. Default is false.
  • flags in regexp.host can be applied.
  • flags in regexp.ipAddress can be applied.
Returns:string
emailAddressList(flags)

Builds a regular expression that matches a list of email addresses.

Parameter Type Description
flags Object
Optional
  • flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ".
  • flags in regexp.emailAddress can be applied.
  • flags in regexp.host can be applied.
  • flags in regexp.ipAddress can be applied.
Returns:string
host(flags)

Builds a RE that matches a host

A host is a named host (A-z0-9_- but not starting with -), a domain name or an IP address, possibly followed by a port number.

Parameter Type Description
flags Object
Optional
  • flags.allowNamed Allow a named host for local networks. Default is false.
  • flags.allowIP Allow an IP address for hostname. Default is true.
  • flags.allowLocal Allow the host to be "localhost". Default is false.
  • flags.allowPort Allow a port number to be present. Default is true.
  • flags in regexp.ipAddress can be applied.
Returns:string
ipAddress(flags)

Builds a RE that matches an IP Address

Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. Supports 2 formats for Ipv6.

Parameter Type Description
flags Object
Optional

All flags are boolean with default = true.

  • flags.allowDottedDecimal Example, 207.142.131.235. No zero padding.
  • flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed.
  • flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed.
  • flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295.
  • flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. Case insensitive. Zero padding allowed.
  • flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits.
Returns:string
numberFormat(flags)

Builds a regular expression to match any sort of number based format

Use this method for phone numbers, social security numbers, zip-codes, etc. The RE can match one format or one of multiple formats.

Format:

  • Stands for a digit, 0-9.

  • ? Stands for an optional digit, 0-9 or nothing.
  • All other characters must appear literally in the expression.
Parameter Type Description
flags Object
Optional
  • flags.format A string or an Array of strings for multiple formats.
Returns:undefined

Examples

Example 1

  • "(###) ###-####" - -> (510) 542-9742
  • "(###) ###-#### x#???" -> (510) 542-9742 x153
  • "###-##-####" - - -> 506-82-1089 - i.e. social security number
  • "#####-####" - - -> 98225-1649 - - i.e. zip code
url(flags)

Builds a regular expression that matches a URL

Parameter Type Description
flags Object
Optional
  • flags.scheme Can be true, false, or [true, false].
  • This means: required, not allowed, or match either one.
  • flags in regexp.host can be applied.
  • flags in regexp.ipAddress can be applied.
Returns:string
Error in the documentation? Can’t find what you are looking for? Let us know!