Deutsch
Der Artikel einer Abkürzung richtet sich immer nach dem Grundwort, dass idR am Ende des Kompositas steht. Hier also "Das Regiment". Die 42 ist nicht Teil der Abkürzung, daher
Das IR 42
bzw nach eurer Schreibweise
Das IR42
English (more detailed)
The gender of German compound words depends on the last part of the new word. So while its
Die Infanterie
Das Regiment
the compound word's article depends on Regiment, so it's as you said
Das Infanterieregiment / Infanterie-Regiment
This is the same for abbreviations and akronyms. The gender depends on the last word. e.g. it's Das BGB (Bürgerliche Gesetzbuch), because of Das Buch; Die AGB (Allgemeine Geschäftsbedingungen) because of Die Bedingungen; Das JaBoG (Jagdbombergeschwader), because of Das Geschwader
Looking at Infanterie Regiment 42 the 42 is not part of the abbreviation/akronym, therefore it's
Das IR 42
or as you write it
Das IR42
And last but not least: Take a look at this article about the Infanterie-Regiment 19 abbreviated as (das) IR 19.