A lookbehind is a zero-length regular-expression assertion: it checks text before the current position without consuming that text. Use it to require or exclude preceding text while matching at the current position. section 12.6 section 12.6.2
Positive lookbehind uses (?<=pattern); negative lookbehind uses (?<!pattern). The pattern must match immediately before the current position—not merely somewhere earlier in the string. section 12.6.2
const kebabCaseRegex = /(?<=[a-z])-([a-z])/g
This pattern matches a hyphen and following lowercase letter only when a lowercase letter immediately precedes the hyphen. section 12.6.2
Mask characters after each name’s first letter
The pattern /(?<=\w)\w/g replaces each word character preceded by another word character. Applied to “Hattori Sato”, it leaves the first letter of each name visible and replaces the rest with asterisks. section 12.6.2
Exclude a negated command
The pattern /(?<!not\s+)strike/gi matches “strike” unless it is preceded by “not” and whitespace, so a replacement can emphasize “Strike at dawn” but leave “do not strike” unchanged. section 12.6.2
Lookbehind assertions were added in ES2018. Regular expressions using them fail in runtimes without support; transpilation does not make them work there. section 1.1.3

