lookBehindBoundary

Pattern that requires a given pattern to precede, without consuming it.

Category: Language Fundamentals > Data Types

Syntax

pat = lookBehindBoundary(p)

Matches a position that is preceded by text matching p.

Description

A look-behind makes a match depend on what is to its left. lookBehindBoundary('dog') + 'cat' matches cat only when it is directly preceded by dog, and the result contains only cat. The related lookAheadBoundary checks what follows instead.

Input arguments

p
Pattern or text that must come immediately before.

Output arguments

pat
A pattern object of zero width: the text matched by p is checked but not included in the result.

Example

Match only after a context

s = 'dogcat catfish';
extract(s, lookBehindBoundary('dog') + 'cat')
Output
ans = "cat"

See also

lookAheadBoundary pattern extract contains regexp