Fix extractByPattern method bug