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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access