Pipe your command to awk, print the 3rd column, a space and the 4th column like this
<command> | awk '{print $3, $4}'
This results in:
12345 KB
or
<command> | awk '{print $3}'
if you want the naked number.
tr helps here.
$ echo "Memory Limit: 12345 KB" | tr -s " " | cut -d " " -f312345
tr -s " "
cut -d " " -f3
You can use awk and avoid using any cut, sed or regex:
awk
<command> | awk '/Memory Limit/{print $(NF-1)}'12345
/Memory Limit/
Memory Limit
$(NF-1)
last-1