It's a well documented swap and very possible.
Costs can vary -- I darn near MADE money swapping a '96 Expo 5.0 into my '02 Ranger. Paid $650 for running/crashed Expo and got just under $450 for the carcass at the scrap yard after I got $250 for a bunch of the interior bits when I was done with it (Yea, that made the 5.0, trans, EFI, etc FREE). Got almost $400 for the 3.0 and trans out of the Ranger.
My 02 is very different than your '97 and many of those differences made the swap easier but still, it's commonly done and very straight forward.
There's always a few snags but the Ranger and Expo share so much that it's a pretty darn easy swap with nearly all the bits, parts and pieces needed OEM from either the Ranger or Expo.
The big thing is the front and rear drive shafts. Those often end up being custom and a bit pricey.