You already know the pos of the delimiter, therefore you could cut it with substr instead?