liveBook · Manning

Lookbehind assertion

A lookbehind assertion is a regular-expression assertion that checks whether a pattern matches before the current position without consuming the checked input.

How 2 Manning books explain it

Secrets of the JavaScript Ninja, Third Edition

A lookbehind is a regular-expression assertion that checks for a pattern immediately before the current position without consuming text.

How it is used
Filters regular-expression matches by testing preceding text without consuming it.
How deep it goes
Explains positive and negative syntax, immediate-position anchoring, and matching through worked examples.
Examples
Uses kebab-case filtering, masking characters in names, and excluding negated strike commands.
What you can do after
Apply it via JavaScript regular expressions to match or replace text according to what immediately precedes it.

Read how Secrets of the JavaScript Ninja, Third Edition explains lookbehind assertion →

The Well-Grounded Rubyist, Fourth Edition

A lookbehind assertion is a regular-expression assertion that checks text immediately preceding the current match position without consuming that text.

How it is used
Constrains Ruby regular-expression matches using text that must or must not precede the target.
How deep it goes
Explains positive and negative syntax plus zero-width behavior, without detailing engine implementation.
Examples
Uses BLACK preceded or not preceded by “David ” as the concrete matching example.
What you can do after
Apply lookbehind assertions in Ruby regular expressions to impose preceding-text conditions without consuming that text.

Read how The Well-Grounded Rubyist, Fourth Edition explains lookbehind assertion →

Also covered in

What to know first

Related concepts

Questions about lookbehind assertion

What is lookbehind assertion?

A lookbehind assertion is a regular-expression assertion that checks whether a pattern matches before the current position without consuming the checked input.

Which Manning books explain lookbehind assertion?

Secrets of the JavaScript Ninja, Third Edition and The Well-Grounded Rubyist, Fourth Edition.

What should I know before learning lookbehind assertion?

Manning books that teach lookbehind assertion usually introduce regular expression first.

What is the difference between lookbehind assertion and Python?

A lookbehind assertion is a regular-expression assertion that checks whether a pattern matches before the current position without consuming the checked input. Python is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.

What is lookbehind assertion a kind of?

Lookbehind assertion is a kind of assertion. A regular-expression assertion tests a condition at a position in the input without consuming characters as part of the match.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.