How i can sed save pattern matches to variables and do something with it? eg

$ echo "string_4.3.2" | sed 's/^string_\([0-9]\)\.\([0-9]\)\.\([0-9]\)$/\1 \2 \3/'

output "4 3 2" but I want to pass variables to function eg

do_something() {
    echo $1
    echo $2
    echo $3
    # .....
    # .....
}

string="string_4.3.2"
if [[ $string =~ `sed ??????` ]]; then
    do_something "$1" "$2" "$3"
fi

Matched numbers need pasing to method "do_something"

Thanks to everyone who tried to help. I found solution:

string="string_4.3.2"
if [[ $string =~ ^string_([0-9])\.([0-9])\.([0-9])$ ]]; then
    do_something "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}"
fi
This question has already been answered. Start a new discussion instead.