Alternative solution without using Regexp