#!/bin/bash

#SERVER_ID_CH_NUM_LENGTH="2" $2
#SET_NUMBER_SEQUENCE_START_WITH="1" $3
   if egrep -q "MissionServer|GAMEDB" <<< "$1" ; then
        SET_GOT="$(sed 's/[a-zA-Z]*\([0-9]\+\)$/\1/g' <<< "$1" | grep -v "[^0-9]")" \
        && echo "$SET_GOT" || echo "Error: cannot get the set number from \"$1\"" | colorize red black 1>&2
   elif egrep -q "WorldServer|ZoneServer|WZ" <<< "$1" ; then
        SET_GOT="$(($(sed "s/[a-zA-Z]*\([0-9]\+\)[0-9]\{$2\}$/\1/g" <<< "$1" | grep -v "[^0-9]")))" \
        && echo "$SET_GOT" || echo "Error: cannot get the set number from \"$1\"" | colorize red black 1>&2
   elif egrep -q "^[0-9]+[01]$" <<< "$1" ; then
        SET_GOT="$(($(sed "s/\([0-9]\+\)[0-9]\{$3\}[01]$/\1/g" <<< "$1" | grep -v "[^0-9]")-$3+1))" \
        && echo "$SET_GOT" || echo "Error: cannot get the set number from \"$1\"" | colorize red black 1>&2
   else
        echo "1"
   fi
