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:5305
Convenience method for creating MustPfx

Returns

MustPfx

Methods

-(s:Str, pfx:Pfx) Source: stdlib.ngs:5325
Return string without the prefix. Throws MatchFail 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")  # MatchFail exception
"abcde" - MaybePfx("xy")  # "abcde"
~(s:Str, pfx:Pfx) Source: stdlib.ngs:5357
Check whether s starts with pfx.

Returns

Match

Example

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