w3resource

Javascript RegExp Objects - Properties and Methods

Description

  • In javascript, Regular expressions are used to perform pattern matches in strings.
  • Can be created by
  • i) Literal syntax. For example, to match 10 digit numbers : var mobileNumber = /\d{10}/.
  • ii)With RegExp constructor function. For example var mobileNumber = new RegExp("\\d{10}", "g").

Javascript RegExp Objects Property

specifies the function that creates an object's prototype.
Name Description Version
constructor Implemented in JavaScript 1.1
global Whether or not to test with the regular expression or not. Implemented in JavaScript 1.2
ignoreCase Whether case is to be ignored during pattern matching in a string Implemented in JavaScript 1.2
input The string against which a regular expression is matched. Implemented in JavaScript 1.2
lastIndex Specifies the index at which to start the next match. Implemented in JavaScript 1.2
lastMatch The last matched characters. Implemented in JavaScript 1.2
multiline Whether search in strings should be performed across multiple lines. Implemented in JavaScript 1.2
prototype Use to add new properties and methods to all instances of a class.
Implemented in JavaScript 1.1
rightContext The substring following the most recent match. Implemented in JavaScript 1.2
source A read-only property that contains the text of the pattern. Implemented in JavaScript 1.2

Javascript RegExp Objects Methods

Name Description Version
compile Use to execute the search for a match in a specified string. Implemented in JavaScript 1.2
exec Executes a search for a match in its string parameter. Implemented in JavaScript 1.2
test Executes a search for a match between a regular expression and a specified string Implemented in JavaScript 1.2
toSource Use to get a string representation (source code) of the object. Implemented in JavaScript 1.3
toString Represent the source code of the specified object. Implemented in JavaScript 1.1

Previous: JavaScript: Regular Expression
Next: JavaScript constructor Property: RegExp Object

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.