> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# string

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/string.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# <span style={{ 'color': 'gray' }}>module</span>  pixeltable.functions.string

Pixeltable UDFs for `StringType`.
It closely follows the Pandas `pandas.Series.str` API.

Example:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import pixeltable as pxt

t = pxt.get_table(...)
t.select(t.str_col.capitalize()).collect()
```

## <span style={{ 'color': 'gray' }}>udf</span>  capitalize()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
capitalize(self: String) -> String
```

Return string with its first character capitalized and the rest lowercased.

Equivalent to [`str.capitalize()`](https://docs.python.org/3/library/stdtypes.html#str.capitalize).

## <span style={{ 'color': 'gray' }}>udf</span>  casefold()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
casefold(self: String) -> String
```

Return a casefolded copy of string.

Equivalent to [`str.casefold()`](https://docs.python.org/3/library/stdtypes.html#str.casefold).

## <span style={{ 'color': 'gray' }}>udf</span>  center()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
center(self: String, width: Int, fillchar: String = ' ') -> String
```

Return a centered string of length `width`.

Equivalent to [`str.center()`](https://docs.python.org/3/library/stdtypes.html#str.center).

**Parameters:**

* **`width`** (`Int`): Total width of the resulting string.
* **`fillchar`** (`String`): Character used for padding.

## <span style={{ 'color': 'gray' }}>udf</span>  contains()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
contains(self: String, substr: String, case: Bool = True) -> Bool
```

Test if string contains a substring.

**Parameters:**

* **`substr`** (`String`): string literal or regular expression
* **`case`** (`Bool`): if False, ignore case

## <span style={{ 'color': 'gray' }}>udf</span>  contains\_re()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
contains_re(self: String, pattern: String, flags: Int = 0) -> Bool
```

Test if string contains a regular expression pattern.

**Parameters:**

* **`pattern`** (`String`): regular expression pattern
* **`flags`** (`Int`): [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module

## <span style={{ 'color': 'gray' }}>udf</span>  count()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
count(self: String, pattern: String, flags: Int = 0) -> Int
```

Count occurrences of pattern or regex.

**Parameters:**

* **`pattern`** (`String`): string literal or regular expression
* **`flags`** (`Int`): [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module

## <span style={{ 'color': 'gray' }}>udf</span>  endswith()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
endswith(self: String, substr: String) -> Bool
```

Return `True` if the string ends with the specified suffix, otherwise return `False`.

Equivalent to [`str.endswith()`](https://docs.python.org/3/library/stdtypes.html#str.endswith).

**Parameters:**

* **`substr`** (`String`): string literal

## <span style={{ 'color': 'gray' }}>udf</span>  fill()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
fill(self: String, width: Int) -> String
```

Wraps the single paragraph in string, and returns a single string containing the wrapped paragraph.

Equivalent to [`textwrap.fill()`](https://docs.python.org/3/library/textwrap.html#textwrap.fill).

**Parameters:**

* **`width`** (`Int`): Maximum line width.
* **`kwargs`** (`Any`): Additional keyword arguments to pass to `textwrap.fill()`.

## <span style={{ 'color': 'gray' }}>udf</span>  find()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
find(
    self: String,
    substr: String,
    start: Int = 0,
    end: Int | None = None
) -> Int
```

Return the lowest index in string where `substr` is found within the slice `s[start:end]`.

Equivalent to [`str.find()`](https://docs.python.org/3/library/stdtypes.html#str.find).

**Parameters:**

* **`substr`** (`String`): substring to search for
* **`start`** (`Int`): slice start
* **`end`** (`Int | None`): slice end

## <span style={{ 'color': 'gray' }}>udf</span>  findall()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
findall(self: String, pattern: String, flags: Int = 0) -> Json
```

Find all occurrences of a regular expression pattern in string.

Equivalent to [`re.findall()`](https://docs.python.org/3/library/re.html#re.findall).

**Parameters:**

* **`pattern`** (`String`): regular expression pattern
* **`flags`** (`Int`): [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module

## <span style={{ 'color': 'gray' }}>udf</span>  format()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
format(self: String) -> String
```

Perform string formatting.

Equivalent to [`str.format()`](https://docs.python.org/3/library/stdtypes.html#str.format).

## <span style={{ 'color': 'gray' }}>udf</span>  fullmatch()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
fullmatch(
    self: String,
    pattern: String,
    case: Bool = True,
    flags: Int = 0
) -> Bool
```

Determine if string fully matches a regular expression.

Equivalent to [`re.fullmatch()`](https://docs.python.org/3/library/re.html#re.fullmatch).

**Parameters:**

* **`pattern`** (`String`): regular expression pattern
* **`case`** (`Bool`): if False, ignore case
* **`flags`** (`Int`): [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module

## <span style={{ 'color': 'gray' }}>udf</span>  index()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
index(
    self: String,
    substr: String,
    start: Int = 0,
    end: Int | None = None
) -> Int
```

Return the lowest index in string where `substr` is found within the slice `[start:end]`.
Raises ValueError if `substr` is not found.

Equivalent to [`str.index()`](https://docs.python.org/3/library/stdtypes.html#str.index).

**Parameters:**

* **`substr`** (`String`): substring to search for
* **`start`** (`Int`): slice start
* **`end`** (`Int | None`): slice end

## <span style={{ 'color': 'gray' }}>udf</span>  isalnum()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isalnum(self: String) -> Bool
```

Return `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](https://docs.python.org/3/library/stdtypes.html#str.isalnum)

## <span style={{ 'color': 'gray' }}>udf</span>  isalpha()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isalpha(self: String) -> Bool
```

Return `True` if all characters in the string are alphabetic and there is at least one character, `False` otherwise.

Equivalent to [`str.isalpha()`](https://docs.python.org/3/library/stdtypes.html#str.isalpha).

## <span style={{ 'color': 'gray' }}>udf</span>  isascii()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isascii(self: String) -> Bool
```

Return `True` if the string is empty or all characters in the string are ASCII, `False` otherwise.

Equivalent to [`str.isascii()`](https://docs.python.org/3/library/stdtypes.html#str.isascii).

## <span style={{ 'color': 'gray' }}>udf</span>  isdecimal()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isdecimal(self: String) -> Bool
```

Return `True` if all characters in the string are decimal characters and there is at least one character, `False`
otherwise.

Equivalent to [`str.isdecimal()`](https://docs.python.org/3/library/stdtypes.html#str.isdecimal).

## <span style={{ 'color': 'gray' }}>udf</span>  isdigit()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isdigit(self: String) -> Bool
```

Return `True` if all characters in the string are digits and there is at least one character, `False` otherwise.

Equivalent to [`str.isdigit()`](https://docs.python.org/3/library/stdtypes.html#str.isdigit).

## <span style={{ 'color': 'gray' }}>udf</span>  isidentifier()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isidentifier(self: String) -> Bool
```

Return `True` if the string is a valid identifier according to the language definition, `False` otherwise.

Equivalent to [`str.isidentifier()`](https://docs.python.org/3/library/stdtypes.html#str.isidentifier)

## <span style={{ 'color': 'gray' }}>udf</span>  islower()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
islower(self: String) -> Bool
```

Return `True` if all cased characters in the string are lowercase and there is at least one cased character,
`False` otherwise.

Equivalent to [`str.islower()`](https://docs.python.org/3/library/stdtypes.html#str.islower)

## <span style={{ 'color': 'gray' }}>udf</span>  isnumeric()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isnumeric(self: String) -> Bool
```

Return `True` if all characters in the string are numeric characters, `False` otherwise.

Equivalent to [`str.isnumeric()`](https://docs.python.org/3/library/stdtypes.html#str.isnumeric)

## <span style={{ 'color': 'gray' }}>udf</span>  isspace()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isspace(self: String) -> Bool
```

Return `True` if there are only whitespace characters in the string and there is at least one character,
`False` otherwise.

Equivalent to [`str.isspace()`](https://docs.python.org/3/library/stdtypes.html#str.isspace)

## <span style={{ 'color': 'gray' }}>udf</span>  istitle()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
istitle(self: String) -> Bool
```

Return `True` if the string is a titlecased string and there is at least one character, `False` otherwise.

Equivalent to [`str.istitle()`](https://docs.python.org/3/library/stdtypes.html#str.istitle)

## <span style={{ 'color': 'gray' }}>udf</span>  isupper()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
isupper(self: String) -> Bool
```

Return `True` if all cased characters in the string are uppercase and there is at least one cased character,
`False` otherwise.

Equivalent to [`str.isupper()`](https://docs.python.org/3/library/stdtypes.html#str.isupper)

## <span style={{ 'color': 'gray' }}>udf</span>  join()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
join(sep: String, elements: Json) -> String
```

Return a string which is the concatenation of the strings in `elements`.

Equivalent to [`str.join()`](https://docs.python.org/3/library/stdtypes.html#str.join)

## <span style={{ 'color': 'gray' }}>udf</span>  len()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
len(self: String) -> Int
```

Return the number of characters in the string.

Equivalent to [`len(str)`](https://docs.python.org/3/library/functions.html#len)

## <span style={{ 'color': 'gray' }}>udf</span>  ljust()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
ljust(self: String, width: Int, fillchar: String = ' ') -> String
```

Return the string left-justified in a string of length `width`.

Equivalent to [`str.ljust()`](https://docs.python.org/3/library/stdtypes.html#str.ljust)

**Parameters:**

* **`width`** (`Int`): Minimum width of resulting string; additional characters will be filled with character defined in
  `fillchar`.
* **`fillchar`** (`String`): Additional character for filling.

## <span style={{ 'color': 'gray' }}>udf</span>  lower()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
lower(self: String) -> String
```

Return a copy of the string with all the cased characters converted to lowercase.

Equivalent to [`str.lower()`](https://docs.python.org/3/library/stdtypes.html#str.lower)

## <span style={{ 'color': 'gray' }}>udf</span>  lstrip()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
lstrip(self: String, chars: String | None = None) -> String
```

Return a copy of the string with leading characters removed. The `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()`](https://docs.python.org/3/library/stdtypes.html#str.lstrip)

**Parameters:**

* **`chars`** (`String | None`): The set of characters to be removed.

## <span style={{ 'color': 'gray' }}>udf</span>  match()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
match(
    self: String,
    pattern: String,
    case: Bool = True,
    flags: Int = 0
) -> Bool
```

Determine if string starts with a match of a regular expression

**Parameters:**

* **`pattern`** (`String`): regular expression pattern
* **`case`** (`Bool`): if False, ignore case
* **`flags`** (`Int`): [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module

## <span style={{ 'color': 'gray' }}>udf</span>  normalize()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
normalize(self: String, form: String) -> String
```

Return the Unicode normal form.

Equivalent to [`unicodedata.normalize()`](https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize)

**Parameters:**

* **`form`** (`String`): Unicode normal form (`'NFC'`, `'NFKC'`, `'NFD'`, `'NFKD'`)

## <span style={{ 'color': 'gray' }}>udf</span>  pad()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
pad(
    self: String,
    width: Int,
    side: String = 'left',
    fillchar: String = ' '
) -> String
```

Pad string up to width

**Parameters:**

* **`width`** (`Int`): Minimum width of resulting string; additional characters will be filled with character defined in
  `fillchar`.
* **`side`** (`String`): Side from which to fill resulting string (`'left'`, `'right'`, `'both'`)
* **`fillchar`** (`String`): Additional character for filling

## <span style={{ 'color': 'gray' }}>udf</span>  partition()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
partition(self: String, sep: String = ' ') -> Json
```

Splits string at the first occurrence of `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.

## <span style={{ 'color': 'gray' }}>udf</span>  removeprefix()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
removeprefix(self: String, prefix: String) -> String
```

Remove prefix. If the prefix is not present, returns string.

## <span style={{ 'color': 'gray' }}>udf</span>  removesuffix()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
removesuffix(self: String, suffix: String) -> String
```

Remove suffix. If the suffix is not present, returns string.

## <span style={{ 'color': 'gray' }}>udf</span>  repeat()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
repeat(self: String, n: Int) -> String
```

Repeat string `n` times.

## <span style={{ 'color': 'gray' }}>udf</span>  replace()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
replace(
    self: String,
    substr: String,
    repl: String,
    n: Int | None = None
) -> String
```

Replace occurrences of `substr` with `repl`.

Equivalent to [`str.replace()`](https://docs.python.org/3/library/stdtypes.html#str.replace).

**Parameters:**

* **`substr`** (`String`): string literal
* **`repl`** (`String`): replacement string
* **`n`** (`Int | None`): number of replacements to make (if `None`, replace all occurrences)

## <span style={{ 'color': 'gray' }}>udf</span>  replace\_re()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
replace_re(
    self: String,
    pattern: String,
    repl: String,
    n: Int | None = None,
    flags: Int = 0
) -> String
```

Replace occurrences of a regular expression pattern with `repl`.

Equivalent to [`re.sub()`](https://docs.python.org/3/library/re.html#re.sub).

**Parameters:**

* **`pattern`** (`String`): regular expression pattern
* **`repl`** (`String`): replacement string
* **`n`** (`Int | None`): number of replacements to make (if `None`, replace all occurrences)
* **`flags`** (`Int`): [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module

## <span style={{ 'color': 'gray' }}>udf</span>  reverse()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
reverse(self: String) -> String
```

Return a reversed copy of the string.

Equivalent to `str[::-1]`.

## <span style={{ 'color': 'gray' }}>udf</span>  rfind()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
rfind(
    self: String,
    substr: String,
    start: Int | None = 0,
    end: Int | None = None
) -> Int
```

Return the highest index where `substr` is found, such that `substr` is contained within `[start:end]`.

Equivalent to [`str.rfind()`](https://docs.python.org/3/library/stdtypes.html#str.rfind).

**Parameters:**

* **`substr`** (`String`): substring to search for
* **`start`** (`Int | None`): slice start
* **`end`** (`Int | None`): slice end

## <span style={{ 'color': 'gray' }}>udf</span>  rindex()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
rindex(
    self: String,
    substr: String,
    start: Int | None = 0,
    end: Int | None = None
) -> Int
```

Return the highest index where `substr` is found, such that `substr` is contained within `[start:end]`.
Raises ValueError if `substr` is not found.

Equivalent to [`str.rindex()`](https://docs.python.org/3/library/stdtypes.html#str.rindex).

## <span style={{ 'color': 'gray' }}>udf</span>  rjust()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
rjust(self: String, width: Int, fillchar: String = ' ') -> String
```

Return the string right-justified in a string of length `width`.

Equivalent to [`str.rjust()`](https://docs.python.org/3/library/stdtypes.html#str.rjust).

**Parameters:**

* **`width`** (`Int`): Minimum width of resulting string.
* **`fillchar`** (`String`): Additional character for filling.

## <span style={{ 'color': 'gray' }}>udf</span>  rpartition()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
rpartition(self: String, sep: String = ' ') -> Json
```

This method splits string at the last occurrence of `sep`, and returns a list containing the part before the
separator, the separator itself, and the part after the separator.

## <span style={{ 'color': 'gray' }}>udf</span>  rstrip()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
rstrip(self: String, chars: String | None = None) -> String
```

Return a copy of string with trailing characters removed.

Equivalent to [`str.rstrip()`](https://docs.python.org/3/library/stdtypes.html#str.rstrip).

**Parameters:**

* **`chars`** (`String | None`): The set of characters to be removed. If omitted or `None`, whitespace characters are removed.

## <span style={{ 'color': 'gray' }}>udf</span>  slice()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
slice(
    self: String,
    start: Int | None = None,
    stop: Int | None = None,
    step: Int | None = None
) -> String
```

Return a slice.

**Parameters:**

* **`start`** (`Int | None`): slice start
* **`stop`** (`Int | None`): slice end
* **`step`** (`Int | None`): slice step

## <span style={{ 'color': 'gray' }}>udf</span>  slice\_replace()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
slice_replace(
    self: String,
    start: Int | None = None,
    stop: Int | None = None,
    repl: String | None = None
) -> String
```

Replace a positional slice with another value.

**Parameters:**

* **`start`** (`Int | None`): slice start
* **`stop`** (`Int | None`): slice end
* **`repl`** (`String | None`): replacement value

## <span style={{ 'color': 'gray' }}>udf</span>  startswith()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
startswith(self: String, substr: String) -> Int
```

Return `True` if string starts with `substr`, otherwise return `False`.

Equivalent to [`str.startswith()`](https://docs.python.org/3/library/stdtypes.html#str.startswith).

**Parameters:**

* **`substr`** (`String`): string literal

## <span style={{ 'color': 'gray' }}>udf</span>  strip()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
strip(self: String, chars: String | None = None) -> String
```

Return a copy of string with leading and trailing characters removed.

Equivalent to [`str.strip()`](https://docs.python.org/3/library/stdtypes.html#str.strip).

**Parameters:**

* **`chars`** (`String | None`): The set of characters to be removed. If omitted or `None`, whitespace characters are removed.

## <span style={{ 'color': 'gray' }}>udf</span>  swapcase()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
swapcase(self: String) -> String
```

Return a copy of string with uppercase characters converted to lowercase and vice versa.

Equivalent to [`str.swapcase()`](https://docs.python.org/3/library/stdtypes.html#str.swapcase).

## <span style={{ 'color': 'gray' }}>udf</span>  title()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
title(self: String) -> String
```

Return a titlecased version of string, i.e. words start with uppercase characters, all remaining cased characters
are lowercase.

Equivalent to [`str.title()`](https://docs.python.org/3/library/stdtypes.html#str.title).

## <span style={{ 'color': 'gray' }}>udf</span>  upper()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
upper(self: String) -> String
```

Return a copy of string converted to uppercase.

Equivalent to [`str.upper()`](https://docs.python.org/3/library/stdtypes.html#str.upper).

## <span style={{ 'color': 'gray' }}>udf</span>  wrap()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
wrap(self: String, width: Int) -> Json
```

Wraps the single paragraph in string so every line is at most `width` characters long.
Returns a list of output lines, without final newlines.

Equivalent to [`textwrap.fill()`](https://docs.python.org/3/library/textwrap.html#textwrap.fill).

**Parameters:**

* **`width`** (`Int`): Maximum line width.
* **`kwargs`** (`Any`): Additional keyword arguments to pass to `textwrap.fill()`.
