Skip to Content | Skip to Navigation


dojo/regexp

Contents

dojo/regexp provides Regular Expression utilities that enhance the RegExp capabilities of JavaScript.

Usage

require["dojo/rexexp"], function(regexp){
  // Escape regular expression strings
  var str = regexp.escapeString(someString);

  // Build Regular Expression Groups
  var str = regexp.buildGroupRE(arrayOfStrings, reFunction);

  // Add a group match to an expression
  var str = regexp.group(someString);
});

buildGroupRE()

Builds a regular expression that groups subexpressions

A utility function used by some of the RE generators. The subexpressions are constructed by the function, re, in the second parameter. re builds one subexpression for each elem in the array a, in the first parameter. Returns a string for a regular expression that groups all the subexpressions.

NameTypeDescription
arrObject|Array

A single value or an array of values.

reFunction

A function. Takes one parameter and converts it to a regular expression.

nonCaptureBoolean

If true, uses non-capturing match, otherwise matches are retained by regular expression. Defaults to false

dojo/regexp::buildGroupRE() returns undefined.

escapeString()

Adds escape sequences for special characters in regular expressions

NameTypeDescription
strString
exceptString

a String with special characters to be left unescaped

dojo/regexp::escapeString() returns undefined.

group()

adds group match to expression

NameTypeDescription
expressionString
nonCaptureBoolean

If true, uses non-capturing match, otherwise matches are retained by regular expression.

dojo/regexp::group() returns string.