Hi Polonel, I'm really sorry to hear about this second attack, martial arts might be a good idea, as long as you don't approach it from the point of view of "preparing yourself for the next time". Martial arts is really only beneficial from an exercise/body-awareness perspective, if you use it as a preparation for physical violence it can get you into more trouble than you need. If I were you, I'd start looking at my general awareness, where my thoughts usually are when I am out walking in the city, do I dissociate a lot? I think the main reason that such things happen to people is 1) lack of general awareness and tendency to dissociate 2) they are an opportunity to learn something important that we are missing. Maybe if you pondered this angle you might find something useful.
Without knowing much about you personally, I think it could be said that, in a general sense, you need concentrate on being more aware of your surroundings.
Apart from that, just try to be more careful! We don't like seeing our friends getting attacked!