Extract duplicated string, use contains() instead of indexOf()