From 28c1c89f194ff91ae20bb579df38540115f44041 Mon Sep 17 00:00:00 2001 From: johannst 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 +

Regular Expressions

+

Zsh supports regular expression matching with the binary operator =~. +The match results can be accessed via the $MATCH variable and +$match indexed array:

+ +
INPUT='title foo : 1234'
+REGEX='^title (.+) : ([0-9]+)$'
+if [[ $INPUT =~ $REGEX ]]; then
+    echo "$MATCH"       # title foo : 1234
+    echo "$match[1]"    # foo
+    echo "$match[2]"    # 1234
+fi
+

Completion

Installation

Completion functions are provided via files and need to be placed in a location -- cgit v1.2.3