improve regex and test (thanks peter