Skip to content

Commit 91e877a

Browse files
authored
Merge pull request #52 from callowayproject/48-documentation-about-regex-backslash-doubling-doesnt-work-as-expected
Fixed documentation regarding regex config.
2 parents 68dd11b + cd71a1a commit 91e877a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docsrc/reference/search-and-replace-config.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ version={new_version}"""
4747

4848
Only the search template will use [Python's regular expression syntax](https://docs.python.org/3/library/re.html#regular-expression-syntax) with minor changes. The template string is rendered using the formatting context. The resulting string is treated as a regular expression for searching unless configured otherwise.
4949

50-
Curly braces (`{}`) and backslashes (`\`) must be doubled in the regular expression to escape them from the string formatting process.
50+
Curly braces (`{}`) must be doubled in the regular expression to escape them from the string-formatting process.
51+
52+
If you are using a TOML-formatted configuration file, you must also escape backslashes (`\`) in the regular expression. The TOML parser will treat a single backslash as an escape character.
5153

5254
The following template:
5355

54-
```text
55-
{current_version} date-released: \\d{{4}}-\\d{{2}}-\\d{{2}}
56+
```toml
57+
# TOML-formatted configuration file
58+
search = "{current_version} date-released: \\d{{4}}-\\d{{2}}-\\d{{2}}"
59+
```
60+
61+
or
62+
63+
```ini
64+
# INI-formatted configuration file
65+
search = "{current_version} date-released: \d{{4}}-\d{{2}}-\d{{2}}"
5666
```
5767

5868
Gets rendered to:

0 commit comments

Comments
 (0)