Minor readability point, but the wall of almost-the-sames looks a little weird to me. If you'd rather not use a regex case statement for some reason, how about elsif?