whitespaceBoundary

Pattern that matches the boundary between whitespace and non-whitespace characters.

Category: Language Fundamentals > Data Types

Syntax

pat = whitespaceBoundary

Creates the boundary pattern.

Description

A boundary pattern does not consume characters. It matches at a spot where whitespace meets a character that is not whitespace, or at the start or end of the text next to a non-whitespace character. It is combined with other patterns using +, | and the other pattern operators.

Because it has no width, it is mostly useful inside a larger pattern or with replace and insertBefore, to mark where words begin and end.

Output arguments

pat
A pattern object. It matches a position, so the match has zero length.

Example

Mark the boundaries

replace("ab  cd", whitespaceBoundary, "|")
Output
ans = "ab|  |cd"

See also

whitespacePattern pattern replace lettersPattern