actually figured out doing command substituion
Code:
#!/bin/bash
function profile() {
d=${1#*_};
d=${d#*_};
d=${d%_*};
d=${d%_*};
echo ${d%_*};
}
profile http://a1.sphotos.ak.fbcdn.net/hphotos-ak-ash3/p480x480/558586_10150802565778254_80329313253_9861803_956204038_n.jpg