diff --git a/docs/clients/promtail/stages/regex.md b/docs/clients/promtail/stages/regex.md index 0cf97ee21b2d0..0df77350b0b3f 100644 --- a/docs/clients/promtail/stages/regex.md +++ b/docs/clients/promtail/stages/regex.md @@ -21,6 +21,20 @@ will be set into the `extracted` map, every capture group **must be named:** `(?Pre)`. The name of the capture group will be used as the key in the extracted map. +Because of how YAML treats backslashes in double-quoted strings, note that all +backslashes in a regex expression must be escaped when using double quotes. For +example, all of these are valid: + +- `expression: \w*` +- `expression: '\w*'` +- `expression: "\\w*"` + +But these are not: + +- `expression: \\w*` (only escape backslashes when using double quotes) +- `expression: '\\w*'` (only escape backslashes when using double quotes) +- `expression: "\w*"` (backslash must be escaped) + ## Example ### Without `source`