Welcome to TRS
No, the 2001-2011 2.3l is a DOHC Mazda L engine so uses a different bolt pattern for transmission
Your 1997 2.3l is a SOHC Lima engine, if a 2WD then 1988-2000 2.3l or 2.5l transmission can be use, model is M5OD-R1(M5R1)
But must be from a 2.3l/2.5l SOHC engine and 2WD, the M5R1s were also used on 3.0l and 4.0l engines but like the 2.3l DOHC they have a different bolt pattern
The M5R1s do not have a detachable bell housing like older manual transmissions did, so they are all Engine Specific
As a side note
Your 1997 was the last year Rangers had the "speedometer cable" hook up on the tail shaft of 2WD transmissions
Speedometer cable was not used but there is a VSS sensor in its place
So if you get a 1998-2000 M5R1 you will need to swap tail shaft housings and move the speedo Drive gear on to the "new" transmission's tail shaft, not a big deal to do