Pfx type

Prefix subsequence of a sequence

Direct parent types

SubSeq
Undocumented
Direct subtypes: 3

Direct children types

MaybePfx
Prefix that might or might not be present for (-) to succeed
MustPfx
Prefix that must be present for ~ matching to succeed

Constructors

Pfx(val:Any) Source: stdlib.ngs:5597
Convenience method for creating MustPfx

Returns

MustPfx

Methods

-(s:Str, pfx:Pfx) Source: stdlib.ngs:5617
Return string without the prefix. Throws InvalidArgument if pfx is MustPfx but s does not start with it.

Parameters

soriginal string
pfxprefix to get rid of

Returns

s without pfx

Example

"abcde" - Pfx("ab")  # "cde"
"abcde" - Pfx("xy")  # InvalidArgument exception
"abcde" - MaybePfx("xy")  # "abcde"
~(s:Str, pfx:Pfx) Source: stdlib.ngs:5667
Check whether s starts with pfx.

Returns

MatchResult

Example

"abcde" ~ Pfx("ab")  # <MatchSuccess matches=['ab'] before= after=cde>
"abcde" ~ Pfx("xy")  # <MatchFailure >