Trait in text coil-stdlib

Pattern

trait Pattern<P>
Import
use text::{Pattern};
Source: src/text.hy

Something a [Searchable] value can be searched for: a plain string (matched literally), or a type such as coil-regex’s Regex.

Spans are byte offsets into the searched string, on character boundaries. Searching from from finds the leftmost match that starts at or after from.

Required methods#

NameDescription
find_inReturns the span of the leftmost match in hay at or after byte from.
is_prefix_ofReturns true when a match starts at the beginning of hay.
is_suffix_ofReturns true when a match ends at the end of hay.
expandReturns the replacement text for the match find_in just returned.

Examples#

use text::{Pattern, Span};
use tests::assert;
let at = "-".find_in("a-b-c", 2) ?? new Span(0, 0);
assert!(at.start == 3 && at.end == 4);

See also#

↑ ↓ navigate ↵ open