The Internet of Vehicles (IoV) is the extension of the Internet of Things (IoT) technology in the field of transportation systems. Ride‐sharing is one of intelligent travel applications in IoV. Ride‐sharing is aimed at taking passengers with similar itineraries and time arrangements to travel in the same car according to a certain matching rule. To effectively integrate transport capacity resources and reduce the number of cars on the road, ride‐sharing has become a popular and economical way of travel. The matching and optimizing of drivers and passengers are the core contents of a ride‐sharing application system. This paper mainly studies the dynamic real‐time matching of passengers and drivers in IoV, considering the main factors such as travel cost, car capacity, and utility. The matching problem is formulated in a ride‐sharing system as a Role‐Based Collaboration (RBC). A new utility method for the matching optimization of ride‐sharing is present. In this paper, we establish a model for simulating the assignment of ride‐sharing with the help of the Environments‐Classes, Agents, Roles, Groups, and Objects (E‐CARGO) model. The objective function and formal definitions are proposed. The utility and time of optimal matching are obtained by using the Kuhn‐Munkres algorithm on the revenue matrix. The experimental results show that the proposed formal method based on the E‐CARGO model and utility theory can be applied in the ride‐sharing problem. Numerical experiments show that the matching time cost increases with the increase of the number of drivers and passengers participating in the ride‐sharing system. When the number of drivers and passengers is different, one‐to‐many matching takes the least time, and one‐to‐one matching takes more time. When the number of drivers and passengers is the same, the time cost of one‐to‐one matching increases sharply with a certain value (bigger than 800). Compared with other matching methods, the time spent by the one‐to‐many method is reduced by 30%. The results show that the proposed solution can be applied to the matching and pricing in a ride‐sharing system.