Add $ operator

This commit is contained in:
Flaviu Tamas 2015-01-18 13:10:19 -05:00
commit 2598909ffd
2 changed files with 4 additions and 0 deletions

View file

@ -104,6 +104,7 @@ is inclusive.
`(captureBounds|captures).toTable` :: returns a table with each named capture `(captureBounds|captures).toTable` :: returns a table with each named capture
as a key. as a key.
`(captureBounds|capture).toSeq` :: returns all the captures by their number. `(captureBounds|capture).toSeq` :: returns all the captures by their number.
`$: string` :: same as `match`
=== Pattern === Pattern

View file

@ -175,6 +175,9 @@ proc toSeq*(pattern: CaptureBounds, default = None[Slice[int]]()): seq[Option[Sl
proc toSeq*(pattern: Captures, default: string = nil): seq[string] = proc toSeq*(pattern: Captures, default: string = nil): seq[string] =
accumulateResult(pattern.items(default)) accumulateResult(pattern.items(default))
proc `$`*(pattern: RegexMatch): string =
return pattern.captures[-1]
# }}} # }}}
# Creation & Destruction {{{ # Creation & Destruction {{{