
Blender has a neat way to transfer all vertex groups from one object to another. In this example I have a prepared pair of trousers on the left with vertex groups, and another pair without any groups.
To transfer, I select the target object first (the one without groups), then SHIFT select the source object (with vertex groups). Notice the selection outlines change: my target object is a darker orange, while the lighter orange object is active. On the right hand side, on the Data Properties tab, find the super tiny arrow icon and choose Copy Vertex Group to Selected.

Boom! Now we have the same vertex groups on the second object. Note that for this to work, both objects need to have the same vertex count and vertex order. If you had a different target object, the operation would fail.