nim-regex icon indicating copy to clipboard operation
nim-regex copied to clipboard

New API

Open nitely opened this issue 3 years ago • 0 comments

API spec:

func re(s: string): Regex
func re(s: static string): static[Regex]
func group(m: RegexMatch; i: int): Slice[int]
func group(m: RegexMatch; s: string): Slice[int]
func groupCount(m: RegexMatch): int
func groupNames(m: RegexMatch): seq[string]
func match(s: string; pattern: Regex): bool
func match(s: string; pattern: Regex; m: var RegexMatch; start = 0): bool
[func,iterator] findAll(s: string; pattern: Regex; start = 0): seq[RegexMatch]
func find(s: string; pattern: Regex; m: var RegexMatch; start = 0): bool
[func,iterator] capture(s: string; pattern: Regex): seq[string]
func contains(s: string; pattern: Regex): bool
[func,iterator] split(s: string; sep: Regex): seq[string]
[func,iterator] splitIncl(s: string; sep: Regex): seq[string]
func startsWith(s: string; pattern: Regex; start = 0): bool
func endsWith(s: string; pattern: Regex): bool
func replace(s: string; pattern: Regex; by: string; limit = 0): string
func replace(s: string; pattern: Regex; by: proc (m: RegexMatch; s: string): string; limit = 0): string 
func isInitialized(re: Regex): bool
func escapeRe(s: string): string
macro match(text: string; regex: RegexLit; body: untyped): untyped

The Captures all group repetitions (not just the last one) feature is removed, we capture the last repetition. This is a breaking change, and it will break some of the APIs. The rest of APIs are deprecated or removed.

nitely avatar Jan 15 '22 20:01 nitely