#!/bin/bash
s='FROM some_registry as registry1
FROM another_registry'
sed 's/.*FROM \(.*\) as.*/\1/;s/FROM //' <<< "$s"