I think that it would be better to use startsWith and endsWith here.