From 28c1c89f194ff91ae20bb579df38540115f44041 Mon Sep 17 00:00:00 2001
From: johannst <johannst@users.noreply.github.com>
Date: Wed, 20 Jan 2021 19:15:48 +0000
Subject: deploy: 77d44129ad468581e860720ccdb7643d5bb25601

---
 tools/zsh.html | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'tools/zsh.html')

diff --git a/tools/zsh.html b/tools/zsh.html
index 2a540ab..6ca18af 100644
--- a/tools/zsh.html
+++ b/tools/zsh.html
@@ -272,6 +272,22 @@ echo $bar[2]          # 2
 echo ${(L)foo}        # aabb
 echo ${(U)foo}        # AABB
 </code></pre>
+<h2><a class="header" href="#regular-expressions" id="regular-expressions">Regular Expressions</a></h2>
+<p>Zsh supports regular expression matching with the binary operator <code>=~</code>.
+The match results can be accessed via the <code>$MATCH</code> variable and
+<code>$match</code> indexed array:</p>
+<ul>
+<li><code>$MATCH</code> contains the full match</li>
+<li><code>$match[1]</code> contains match of the first capture group</li>
+</ul>
+<pre><code class="language-zsh">INPUT='title foo : 1234'
+REGEX='^title (.+) : ([0-9]+)$'
+if [[ $INPUT =~ $REGEX ]]; then
+    echo &quot;$MATCH&quot;       # title foo : 1234
+    echo &quot;$match[1]&quot;    # foo
+    echo &quot;$match[2]&quot;    # 1234
+fi
+</code></pre>
 <h2><a class="header" href="#completion" id="completion">Completion</a></h2>
 <h3><a class="header" href="#installation" id="installation">Installation</a></h3>
 <p>Completion functions are provided via files and need to be placed in a location
-- 
cgit v1.2.3