bugfix regex infinite loop and resource eating

I have to change this regex because it causes ruby process to reach 100% of cpu.
Please, check if its ok.