get substr?

Hi,
I have a long string like,

aabab|bcbcbcbbc|defgh|paswd123 dedededede|efef|ghijklmn|paswd234 ghghghghgh|ijijii|klllkkk|paswd345 lmlmlmmm|nononononn|opopopopp|paswd456

This string is devided into one space between substrings. This substrings are,

aabab|bcbcbcbbc|defgh|paswd123
dedededede|efef|ghijklmn|paswd234
ghghghghgh|ijijii|klllkkk|paswd345
lmlmlmmm|nononononn|opopopopp|paswd456

Now i want to get paswd234 by searching corresponding ghijklmn
similarly want to get paswd345 by searching corresponding klllkkk

But above long string is dynamic, means may be some more substrings can add to this long string or may be some substrings can be removed from this long string.
could any one pls help me in this.
Thanks in advance.

Forgot to mention one thing, In this long string

aabab|bcbcbcbbc|defgh|paswd123 dedededede|efef|ghijklmn|paswd234 ghghghghgh|ijijii|klllkkk|paswd345 lmlmlmmm|nononononn|opopopopp|paswd456

sometimes paswd234(8 chars) length may get change to less or more of 8 chars. Means the long string may be like,

aabab|bcbcbcbbc|defgh|passwd123 dedededede|efef|ghijklmn|pasd234 ghghghghgh|ijijii|klllkkk|pd345 lmlmlmmm|nononononn|opopopopp|passswwd456

Do you want password for ghijklmn and klllkkk alone or do you want all the passwords ?

For all passwords

tr ' ' '\n' < input.txt | sed -n -e "s/.*|\(.*\)/\1/p"

Thanks for your solution Vino,

I want pasword for individual. Actually i will give only one search string and want to fetch corresponding pasword for one execution of the command.

for example,
the search string is ghijklmn
and i want corresponding pasword.

Then modify the sed script to only print when that particular key is matched.

string=ghijklmn
sed -n -e "s/.*${string}|\([^ ]*\) .*/\1/p" input.txt

But I think you would be better off with this sed statement and the above tr statement. Lest you dont run into a command too long.

Thanks for your replies vino
your command is working fine.
but i am sorry, i didnt give correct input string. it is like,

aab.a0b|bcbc1bcbbc|de_f2gh|paswd123 dede.ded.ede|ef_ef|ghi_jklm0n|paswd234 gh.ghgh.ghgh|ijijii|k_ll4lkkk|paswd345 lml.mlmmm|nononononn|op_opop_opp0|paswd456

This string is having . and _ so couldnt get result for me.
can you pls take the above string as an input string and can you give the command.