Skip to content

Commit f353e8c

Browse files
committed
reference: move regex functions to their own section
Signed-off-by: Luca Zeuch <[email protected]>
1 parent 195eb8a commit f353e8c

File tree

1 file changed

+66
-62
lines changed

1 file changed

+66
-62
lines changed

content/docs/reference/templates/functions.md

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,70 @@ Unpins the specified message.
14421442

14431443
---
14441444

1445-
## Role functions
1445+
## Regex Functions
1446+
1447+
#### reFind
1448+
1449+
```yag
1450+
{{ $result := reFind <regex> <text> }}
1451+
```
1452+
1453+
Returns the first match of the regular expression `regex` in `text`, or the empty string if the pattern did not match
1454+
anywhere.
1455+
1456+
#### reFindAll
1457+
1458+
```yag
1459+
{{ $result := reFindAll <regex> <text> [count] }}
1460+
```
1461+
1462+
Returns a slice of successive matches of `regex` in `text`. If `count` is provided, the number of matches is limited to
1463+
that amount; otherwise, all matches are returned.
1464+
1465+
#### reFindAllSubmatches
1466+
1467+
```yag
1468+
{{ $result := reFindAllSubmatches <regex> <text> [count] }}
1469+
```
1470+
1471+
Returns a slice of successive submatches of `regex` in `text`. Each submatch is itself a slice containing the match of
1472+
the entire expression, followed by any matches of capturing groups. If `count` is provided, the number of submatches is
1473+
limited to that amount; otherwise, all submatches are returned.
1474+
1475+
#### reQuoteMeta
1476+
1477+
```yag
1478+
{{ $result := reQuoteMeta <string> }}
1479+
```
1480+
1481+
Escapes all regular expression metacharacters in the input `string`; the result is a regular expression matching the
1482+
literal input string.
1483+
1484+
#### reReplace
1485+
1486+
```yag
1487+
{{ $result := reReplace <regex> <text> <replacement> }}
1488+
```
1489+
1490+
Replaces all matches of `regex` in `text` with `replacement`.
1491+
1492+
#### reSplit
1493+
1494+
```yag
1495+
{{ $result := reSplit <regex> <text> [count] }}
1496+
```
1497+
1498+
Splits the `text` around each match of `regex`, returning a slice of delimited substrings.
1499+
1500+
if the `count` parameter is specified, it limits the number of substrings to return:
1501+
1502+
- `count > 0`: at most `count` substrings; the last substring will be the unsplit remainder;
1503+
- `count == 0`: the result is `nil` (zero substrings);
1504+
- `count < 0`: all substrings.
1505+
1506+
---
1507+
1508+
## Role Functions
14461509

14471510
#### addRole
14481511

@@ -1667,7 +1730,7 @@ Reports whether the specified target has the specified role name (case-insensiti
16671730

16681731
---
16691732

1670-
## String manipulation
1733+
## String Manipulation
16711734

16721735
{{< callout context="note" title="Note: RegEx Limitations" icon="outline/info-circle" >}}
16731736

@@ -1741,65 +1804,6 @@ the end.
17411804

17421805
Interpolates `args...` according to `format`. See the [Go `fmt` package documentation](https://pkg.go.dev/fmt).
17431806

1744-
#### reFind
1745-
1746-
```yag
1747-
{{ $result := reFind <regex> <text> }}
1748-
```
1749-
1750-
Returns the first match of the regular expression `regex` in `text`, or the empty string if the pattern did not match
1751-
anywhere.
1752-
1753-
#### reFindAll
1754-
1755-
```yag
1756-
{{ $result := reFindAll <regex> <text> [count] }}
1757-
```
1758-
1759-
Returns a slice of successive matches of `regex` in `text`. If `count` is provided, the number of matches is limited to
1760-
that amount; otherwise, all matches are returned.
1761-
1762-
#### reFindAllSubmatches
1763-
1764-
```yag
1765-
{{ $result := reFindAllSubmatches <regex> <text> [count] }}
1766-
```
1767-
1768-
Returns a slice of successive submatches of `regex` in `text`. Each submatch is itself a slice containing the match of
1769-
the entire expression, followed by any matches of capturing groups. If `count` is provided, the number of submatches is
1770-
limited to that amount; otherwise, all submatches are returned.
1771-
1772-
#### reQuoteMeta
1773-
1774-
```yag
1775-
{{ $result := reQuoteMeta <string> }}
1776-
```
1777-
1778-
Escapes all regular expression metacharacters in the input `string`; the result is a regular expression matching the
1779-
literal input string.
1780-
1781-
#### reReplace
1782-
1783-
```yag
1784-
{{ $result := reReplace <regex> <text> <replacement> }}
1785-
```
1786-
1787-
Replaces all matches of `regex` in `text` with `replacement`.
1788-
1789-
#### reSplit
1790-
1791-
```yag
1792-
{{ $result := reSplit <regex> <text> [count] }}
1793-
```
1794-
1795-
Splits the `text` around each match of `regex`, returning a slice of delimited substrings.
1796-
1797-
if the `count` parameter is specified, it limits the number of substrings to return:
1798-
1799-
- `count > 0`: at most `count` substrings; the last substring will be the unsplit remainder;
1800-
- `count == 0`: the result is `nil` (zero substrings);
1801-
- `count < 0`: all substrings.
1802-
18031807
#### sanitizeText
18041808

18051809
```yag
@@ -1998,7 +2002,7 @@ can be done using the `print` function:
19982002

19992003
---
20002004

2001-
## Type conversion
2005+
## Type Conversion
20022006

20032007
#### structToSdict
20042008

0 commit comments

Comments
 (0)