aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cond-regexp.sub
diff options
context:
space:
mode:
authorcvpcs <root@cvpcs.org>2010-06-02 11:02:31 -0500
committercvpcs <root@cvpcs.org>2010-06-02 11:02:31 -0500
commit772f20abb0a3a0979c440114bf3a1cff5b3cef03 (patch)
tree3384b9291d73a12542c526a8557218c7435491b0 /tests/cond-regexp.sub
downloadexternal_bash-772f20abb0a3a0979c440114bf3a1cff5b3cef03.zip
external_bash-772f20abb0a3a0979c440114bf3a1cff5b3cef03.tar.gz
external_bash-772f20abb0a3a0979c440114bf3a1cff5b3cef03.tar.bz2
initial import of bash 4.1
Diffstat (limited to 'tests/cond-regexp.sub')
-rw-r--r--tests/cond-regexp.sub42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/cond-regexp.sub b/tests/cond-regexp.sub
new file mode 100644
index 0000000..724957d
--- /dev/null
+++ b/tests/cond-regexp.sub
@@ -0,0 +1,42 @@
+VAR='[[:alpha:]]'
+
+[[ $VAR =~ '[[:alpha:]]' ]] && echo match 1
+
+[[ a =~ '[[:alpha:]]' ]] || echo match 2
+
+[[ a =~ [[:alpha:]] ]] && echo match 3
+
+[[ a =~ $VAR ]] && echo match 4
+
+[[ a =~ "$VAR" ]] || echo match 5
+
+line=aab
+[[ $line =~ [[:space:]]*(a)?b ]] && echo match 6
+
+V="alphabet"
+[[ $V == alphabet ]] && echo yes 1
+[[ $V == "alphabet" ]] && echo yes 2
+[[ $V == 'alphabet' ]] && echo yes 3
+[[ $V =~ alphabet ]] && echo yes 4
+[[ $V =~ "alphabet" ]] && echo yes 5
+[[ $V =~ 'alphabet' ]] && echo yes 6
+
+DOG="Dog name - 01 - Wiggles"
+REPAT='([[:alpha:][:blank:]]*)- ([[:digit:]]*) - (.*)$'
+if [[ $DOG =~ ([[:alpha:][:blank:]]*)-\ ([[:digit:]]*)\ -\ (.*)$ ]]
+then
+ echo Dog ${BASH_REMATCH[2]} is ${BASH_REMATCH[3]}
+fi
+if [[ $DOG =~ $REPAT ]]
+then
+ echo Dog ${BASH_REMATCH[2]} is ${BASH_REMATCH[3]}
+fi
+
+[[ $REPAT =~ "$REPAT" ]] && echo rematch 1
+
+v="one two buckle my shoe"
+[[ ${v} =~ "one two" ]] && echo matches 7
+
+[[ ${v} =~ (one two) ]] && echo matches 8
+
+[[ ${v} =~ one\ two ]] && echo matches 9