Name

leftContext, rightContext — NN 4 IE J3 ECMA n/a

Synopsis

Read-only

The leftContext property returns the string starting with the beginning of the most recent searched text up to, but not including, the matching string. The rightContext property returns the string starting with the main string portion immediately following the matching string and extending to the end of the string. The short versions are $' and $', respectively. Because the start of subsequent searches on the same main string move inexorably toward the end of the main string, the starting point of the leftContext value can shift with each operation.

Example

var wholeContext = RegExp.leftContext + RegExp.lastMatch + RegExp.rightContext

Value

String.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.