module pixeltable.functions.string
Pixeltable UDFs forStringType.
It closely follows the Pandas pandas.Series.str API.
Example:
udf capitalize()
Signature
str.capitalize().
udf casefold()
Signature
str.casefold().
udf center()
Signature
width.
Equivalent to str.center().
Parameters:
width(pxt.Int): Total width of the resulting string.fillchar(pxt.String): Character used for padding.
udf contains()
Signature
substr(pxt.String): string literal or regular expressioncase(pxt.Bool): if False, ignore case
udf contains_re()
Signature
pattern(pxt.String): regular expression patternflags(pxt.Int): flags for theremodule
udf count()
Signature
pattern(pxt.String): string literal or regular expressionflags(pxt.Int): flags for theremodule
udf endswith()
Signature
True if the string ends with the specified suffix, otherwise return False.
Equivalent to str.endswith().
Parameters:
substr(pxt.String): string literal
udf fill()
Signature
textwrap.fill().
Parameters:
width(pxt.Int): Maximum line width.kwargs(Any): Additional keyword arguments to pass totextwrap.fill().
udf find()
Signature
substr is found within the slice s[start:end].
Equivalent to str.find().
Parameters:
substr(pxt.String): substring to search forstart(pxt.Int): slice startend(pxt.Int | None): slice end
udf findall()
Signature
re.findall().
Parameters:
pattern(pxt.String): regular expression patternflags(pxt.Int): flags for theremodule
udf format()
Signature
str.format().
udf fullmatch()
Signature
re.fullmatch().
Parameters:
pattern(pxt.String): regular expression patterncase(pxt.Bool): if False, ignore caseflags(pxt.Int): flags for theremodule
udf index()
Signature
substr is found within the slice [start:end].
Raises ValueError if substr is not found.
Equivalent to str.index().
Parameters:
substr(pxt.String): substring to search forstart(pxt.Int): slice startend(pxt.Int | None): slice end
udf isalnum()
Signature
True if all characters in the string are alphanumeric and there is at least one character, False
otherwise.
Equivalent to [str.isalnum()](https://docs.python.org/3/library/stdtypes.html#str.isalnum
udf isalpha()
Signature
True if all characters in the string are alphabetic and there is at least one character, False otherwise.
Equivalent to str.isalpha().
udf isascii()
Signature
True if the string is empty or all characters in the string are ASCII, False otherwise.
Equivalent to str.isascii().
udf isdecimal()
Signature
True if all characters in the string are decimal characters and there is at least one character, False
otherwise.
Equivalent to str.isdecimal().
udf isdigit()
Signature
True if all characters in the string are digits and there is at least one character, False otherwise.
Equivalent to str.isdigit().
udf isidentifier()
Signature
True if the string is a valid identifier according to the language definition, False otherwise.
Equivalent to str.isidentifier()
udf islower()
Signature
True if all cased characters in the string are lowercase and there is at least one cased character,
False otherwise.
Equivalent to str.islower()
udf isnumeric()
Signature
True if all characters in the string are numeric characters, False otherwise.
Equivalent to str.isnumeric()
udf isspace()
Signature
True if there are only whitespace characters in the string and there is at least one character,
False otherwise.
Equivalent to str.isspace()
udf istitle()
Signature
True if the string is a titlecased string and there is at least one character, False otherwise.
Equivalent to str.istitle()
udf isupper()
Signature
True if all cased characters in the string are uppercase and there is at least one cased character,
False otherwise.
Equivalent to str.isupper()
udf join()
Signature
elements.
Equivalent to str.join()
udf len()
Signature
len(str)
udf ljust()
Signature
width.
Equivalent to str.ljust()
Parameters:
width(pxt.Int): Minimum width of resulting string; additional characters will be filled with character defined infillchar.fillchar(pxt.String): Additional character for filling.
udf lower()
Signature
str.lower()
udf lstrip()
Signature
chars argument is a string specifying the set of
characters to be removed. If omitted or None, whitespace characters are removed.
Equivalent to str.lstrip()
Parameters:
chars(pxt.String | None): The set of characters to be removed.
udf match()
Signature
pattern(pxt.String): regular expression patterncase(pxt.Bool): if False, ignore caseflags(pxt.Int): flags for theremodule
udf normalize()
Signature
unicodedata.normalize()
Parameters:
form(pxt.String): Unicode normal form ('NFC','NFKC','NFD','NFKD')
udf pad()
Signature
width(pxt.Int): Minimum width of resulting string; additional characters will be filled with character defined infillchar.side(pxt.String): Side from which to fill resulting string ('left','right','both')fillchar(pxt.String): Additional character for filling
udf partition()
Signature
sep, and returns 3 elements containing the part before the
separator, the separator itself, and the part after the separator. If the separator is not found, return 3 elements
containing string itself, followed by two empty strings.
udf removeprefix()
Signature
udf removesuffix()
Signature
udf repeat()
Signature
n times.
udf replace()
Signature
substr with repl.
Equivalent to str.replace().
Parameters:
substr(pxt.String): string literalrepl(pxt.String): replacement stringn(pxt.Int | None): number of replacements to make (ifNone, replace all occurrences)
udf replace_re()
Signature
repl.
Equivalent to re.sub().
Parameters:
pattern(pxt.String): regular expression patternrepl(pxt.String): replacement stringn(pxt.Int | None): number of replacements to make (ifNone, replace all occurrences)flags(pxt.Int): flags for theremodule
udf reverse()
Signature
str[::-1].
udf rfind()
Signature
substr is found, such that substr is contained within [start:end].
Equivalent to str.rfind().
Parameters:
substr(pxt.String): substring to search forstart(pxt.Int | None): slice startend(pxt.Int | None): slice end
udf rindex()
Signature
substr is found, such that substr is contained within [start:end].
Raises ValueError if substr is not found.
Equivalent to str.rindex().
udf rjust()
Signature
width.
Equivalent to str.rjust().
Parameters:
width(pxt.Int): Minimum width of resulting string.fillchar(pxt.String): Additional character for filling.
udf rpartition()
Signature
sep, and returns a list containing the part before the
separator, the separator itself, and the part after the separator.
udf rstrip()
Signature
str.rstrip().
Parameters:
chars(pxt.String | None): The set of characters to be removed. If omitted orNone, whitespace characters are removed.
udf slice()
Signature
start(pxt.Int | None): slice startstop(pxt.Int | None): slice endstep(pxt.Int | None): slice step
udf slice_replace()
Signature
start(pxt.Int | None): slice startstop(pxt.Int | None): slice endrepl(pxt.String | None): replacement value
udf startswith()
Signature
True if string starts with substr, otherwise return False.
Equivalent to str.startswith().
Parameters:
substr(pxt.String): string literal
udf strip()
Signature
str.strip().
Parameters:
chars(pxt.String | None): The set of characters to be removed. If omitted orNone, whitespace characters are removed.
udf swapcase()
Signature
str.swapcase().
udf title()
Signature
str.title().
udf upper()
Signature
str.upper().
udf wrap()
Signature
width characters long.
Returns a list of output lines, without final newlines.
Equivalent to textwrap.fill().
Parameters:
width(pxt.Int): Maximum line width.kwargs(Any): Additional keyword arguments to pass totextwrap.fill().
udf zfill()
Signature
0 on the left to a total length of width.
Equivalent to str.zfill().
Parameters:
width(pxt.Int): Minimum width of resulting string.