#!/bin/bash

# ere-match-test
#
# demo that an ERE does indeed work with =~ in [[ ]]
#
# by: Sharon Tuttle
# last modified: 2022-10-19

filename=$1

while read next_line
do
    # below are several of the patterns we tried out in class
    #     on 2022-10-19

    # if [[ "$next_line" =~ (dog|cat)(fish|fight) ]]
    
    # if [[ "$next_line" =~ ^([A-Z]|[0-9])+$ ]]

    # if [[ "$next_line" =~ ^([a-z]|[0-9]){4}$ ]]

    if [[ "$next_line" =~ ^(\+|-)?[0-9]+$ ]] 
    then
        echo "matched:     $next_line"
    else
        # echo -n "not matched: $next_line"
	echo -n ""
    fi
done < "$filename"