Extract single word from lines

Hi I have a huge line like the following:
this word and many other words AA122134 other and other words and AA224466 and other other other other word AA667210 words

I only want extract the words AA?????? and put them in a column, how could i do ?
thx so much!

See the following code:

sed 's/ /\n/g' data | grep "^AA" | tr "\n" " "

[OR]

cat data | tr " " "\n"| sed -n '/^AA/p' | tr "\n" " "

[OR]

egrep -wo --color "AA[^ ]*?" data | tr "\n" " "

OK ! :b:

Try this,

cat file  | tr ' ' '\n' | sed -rne "/(AA[0-9]{6})/P" | tr "\n" " "

Or shorter:

awk '/^AA*/' RS=" " file

Try:

perl -lane '$,="\n"; print grep {/AA\d+/} @F' file

or,

sed 's/[a-z]*//g' file | xargs -n1
egrep -wo "AA[0-9]{6}" infile
perl -wlne ' undef $/ ; print $1 while (/.*?\s+(AA\d+)\s+.*?/g) ;'

:p:p:p