I think you went the right way. The 2nd one is much closer to working than the first. I'm not even entirely sure what $wang was supposed to hold.
Also, I would have missed the \w+.
--
I used to drive a Heisenbergmobile, but everyone I looked at the speedometer, I got lost.