Parashas Bamidbar
קַ֣ח אֶת־הַלְוִיִּ֗ם תַּ֤חַת כׇּל־בְּכוֹר֙ בִּבְנֵ֣י יִשְׂרָאֵ֔ל וְאֶת־בֶּהֱמַ֥ת הַלְוִיִּ֖ם תַּ֣חַת בְּהֶמְתָּ֑ם וְהָיוּ־לִ֥י הַלְוִיִּ֖ם אֲנִ֥י יְהֹוָֽה׃
Take the Levites in place of all the male first-born among the Israelite people, and the cattle of the Levites in place of their cattle; and the Levites shall be Mine, GOD’s.
Torah Temimah points to TT (second unit) (verified).
תחת בהמתם —\ldots ואם יש לו כמה ספיקות פטר חמור.
English: “In place of their animals” — \ldots and if he has several doubtful firstborn donkeys [the same principle applies].
Custom
Chazal apply the substitution principle even to doubtful cases of firstborn animals.