Regexp matching replaced with reflection