Skip to main content

# Substring

Finds a string in a larger string.

## Syntax

```substring(String, List, Integer)
```

## Description

Given a string $s$, a list of strings $\left\{{s}_{1},...,{s}_{k}\right\}$, and a positive integer $n$, searches ${s}_{i}$ in $s$ starting from the $n$-th char. If more than one ${s}_{j}$ appears in the original string, only the first appearance is returned. If the find ends with no matches, `failed` is returned. The output is a list with two elements: an integer with the position of the string and the string ${s}_{i}$.

Given a string $s$ and a list of strings $\left\{{s}_{1},...,{s}_{k}\right\}$, searches ${s}_{i}$ in $s$. If more than one ${s}_{j}$ appears in the original string, only the first appearance is returned. If the find ends with no matches, `failed` is returned. The output is a list with two elements: an integer with the position of the string and the string ${s}_{i}$.

### Nota

The math content is converted to MathML inside the corresponding string if there is a special character or any mathematical expression in the string. For instance, if the kernel receives `s = "2 [itex]<mo>.</mo>[/itex] 17"`, the substring function won't return the expected value. In this case, you need to include the string previously through the code editor.