Wouldn't this make more sense as a regexp? This seems ugly.