#!/bin/bash
# trying out the BASH_REMATCH array, filled with matching
# subexpressions from a regular expression match
#
# expects: one command line argument, a string that it will try
# to match with a regular expression with subexpressions
#
# by: Sharon Tuttle
# last modified: 10-24-12
line=$1
echo "pre-if: <$line>"
if [[ "$line" =~ a(.*)b(.*)c(.*)d ]]
then
i=0
for match in "${BASH_REMATCH[@]}"
do
echo "\${BASH_REMATCH[$i]} is <${BASH_REMATCH[$i]}>"
let i=i+1
done
fi