This is just a simple sed to capture IP address from ping. Note host must allow ICMP. This was tested on sh, bash and zsh.
sed -nE ‘s/^PING[^(]+\(([^)]+)\).*/\1/p’
An example:
ping ifconfig.me | sed -nE 's/^PING[^(]+\(([^)]+)\).*/\1/p'
216.239.36.21