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.
Here is limitation - href should be first arg. It is not true sometimes.