Complex sentence: By the end of 1864, the regiment was fighting in the Shenandoah Valley attached to General George Armstrong Custer's 3rd Division, Cavalry Corps, Army of the Potomac.
Split into simpler sentences: By the end of 1864, the regiment was fighting in the Shenandoah Valley under the command of General George Armstrong Custer. It finished attached to the 3rd Division, Cavalry Corps, Army of the Potomac.