package
0.5.0
Repository: https://github.com/qri-io/starlib.git
Documentation: pkg.go.dev

# README

re

re defines regular expression functions, it's intended to be a drop-in subset of python's re module for starlark: https://docs.python.org/3/library/re.html

Functions

findall(pattern, text, flags=0)

Returns all non-overlapping matches of pattern in string, as a list of strings. The string is scanned left-to-right, and matches are returned in the order found. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.

parameters:

nametypedescription
patternstringregular expression pattern string
textstringstring to find within
flagsintinteger flags to control regex behaviour. reserved for future use

split(pattern, text, maxsplit=0, flags=0)

Split text by the occurrences of pattern. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list.

parameters:

nametypedescription
patternstringregular expression pattern string
textstringinput string to split
maxsplitintmaximum number of splits to make. default 0 splits all matches
flagsintinteger flags to control regex behaviour. reserved for future use

sub(pattern, repl, text, count=0, flags=0)

Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. If the pattern isn’t found, string is returned unchanged. repl can be a string or a function; if it is a string, any backslash escapes in it are processed. That is, \n is converted to a single newline character, \r is converted to a carriage return, and so forth.

parameters:

nametypedescription
patternstringregular expression pattern string
replstringstring to replace matches with
textstringinput string to replace
countintnumber of replacements to make, default 0 means replace all matches
flagsintinteger flags to control regex behaviour. reserved for future use