#!/bin/bash
# demonstrate a clicker answer from Week 10 Lecture 1,
# regarding the BASH_REMATCH array
#
# expects: one command line argument, which will be compared
# to a regular expression
# by: Sharon Tuttle
# last modified: 10-24-12
line=$1
echo "pre-if: $line"
if [[ "$line" =~ moo(.+)moo(.+)moo ]]
then
echo "<${BASH_REMATCH[0]}>"
echo "<${BASH_REMATCH[1]}>"
echo "<${BASH_REMATCH[2]}>"
echo "<${#BASH_REMATCH[*]}>"
fi