summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-01-03 22:52:15 +1100
committerMaxime Coste <mawww@kakoune.org>2019-01-03 22:55:50 +1100
commit328c497be248faf4e13aaececaf849c844c59efe (patch)
treeeb3d225fc81389afc8938593f065cf715804d75d /doc
parent56ee329d79d076742e60c10974c471cc8119ed05 (diff)
Add support for named captures to the regex impl and regex highlighter
ECMAScript is adding support for it, and it is a pretty isolated change to do. Fixes #2293
Diffstat (limited to 'doc')
-rw-r--r--doc/pages/highlighters.asciidoc4
-rw-r--r--doc/pages/regex.asciidoc16
2 files changed, 14 insertions, 6 deletions
diff --git a/doc/pages/highlighters.asciidoc b/doc/pages/highlighters.asciidoc
index ea6500cd..18504b3c 100644
--- a/doc/pages/highlighters.asciidoc
+++ b/doc/pages/highlighters.asciidoc
@@ -99,6 +99,10 @@ from the remaining parameters.
add-highlighter window/ regex //\h*(TODO:)[^\n]* 0:cyan 1:yellow,red
--------------------------------------------------------------------
+ capture_id can be either the capture number, or its name if a
+ named capture is used in the regex (See
+ <<regex#Groups, `:doc regex Groups`>>)
+
*dynregex* <expression> <capture_id>:<face> ...::
similar to regex, but expand (like a command parameter would) the
given expression before building a regex from the result.
diff --git a/doc/pages/regex.asciidoc b/doc/pages/regex.asciidoc
index e228c25f..a43fc589 100644
--- a/doc/pages/regex.asciidoc
+++ b/doc/pages/regex.asciidoc
@@ -78,17 +78,21 @@ Regex atoms can be grouped using `(` and `)` or `(?:` and `)`. If `(` is
used, the group will be a capturing group, which means the positions from
the subject strings that matched between `(` and `)` will be recorded.
-Capture groups are numbered starting at 1. They are numbered in the order of
-appearance of their `(` in the regex. A special capture group 0 is
-for the whole sequence that matched.
+Capture groups are numbered starting at 1. They are numbered in the
+order of appearance of their `(` in the regex. A special capture group
+0 is for the whole sequence that matched.
-`(?:` introduces a non capturing group, which will not record the
+* `(?:` introduces a non capturing group, which will not record the
matching positions.
+* `(?<name>` introduces a named capturing group, which, in addition to
+being referred by number, can be, in certain contexts, referred by the
+given name.
+
== Alternations
-`|` introduces an alternation, which will either match its left-hand side,
-or its right-hand side (preferring the left-hand side)
+The `|` character introduces an alternation, which will either match
+its left-hand side, or its right-hand side (preferring the left-hand side)
For example, `foo|bar` matches either `foo` or `bar`, `foo(bar|baz|qux)`
matches `foo` followed by either `bar`, `baz` or `qux`.