Yes, in ancient times that used to be the practice when a Dvija used to spend 48 years in the Brahmacharya Ashrama (the student phase of life). And, in that phase, maintaining celibacy is to be fulfilled as it's a vow.
The Baudhayana Dharma Sutras state that:
1 Forty-eight years, according to ancient practice, is the period
of studentship for studying the Veda; 2 alternatively, twenty-four
years, or twelve years per Veda, 3 or at least one year for each book,
4 or, given the uncertainty of life, until he has learned it. 5 A
vedic text states: ‘A man should establish his sacred fires while his
hair is still black.’
Dharmasutras of Baudhayana 1.3.1-5
And, note that it's applicable for any Dvija and not only for the Brahmins.