From 4b35dab8916b9c88336a776eaaadd8e6746a50b6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 18 Jul 2018 10:23:26 -0400 Subject: Help: Document how escape sequences work in a regex Our regex engine doesn't interpret `\`-escapes but CMake language escape sequences may be used to pass literal whitespace characters to it. --- Help/command/string.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Help/command/string.rst b/Help/command/string.rst index efa923b..29a153a 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -151,6 +151,20 @@ has lower precedence than concatenation. This means that the regular expression ``^ab+d$`` matches ``abbd`` but not ``ababd``, and the regular expression ``^(ab|cd)$`` matches ``ab`` but not ``abd``. +Backslash (``\``) characters in regular expressions are interpreted +literally and do not escape anything or represent placeholders. +However, CMake language :ref:`Escape Sequences` such as ``\t``, +``\r``, ``\n``, and ``\\`` may be used to construct literal tabs, +carriage returns, newlines, and backslashes (respectively) to pass +in a regex. For example: + +* The quoted argument ``"[ \t\r\n]"`` specifies a regex that matches + any single whitespace character. +* The quoted argument ``"[/\\]"`` specifies a regex that matches + a single forward slash ``/`` or backslash ``\``. +* The quoted argument ``"[A-Za-z0-9_]"`` specifies a regex that matches + any single "word" character in the C locale. + Manipulation ^^^^^^^^^^^^ -- cgit v0.12