I can’t find where the syllabus 구 comes from. What does 구 mean?
As @user2326230 said, '구' in the '구남친' means old or ex-.
This 구 is written as 舊 in Chinese. https://hanja.dict.naver.com/#/entry/ccko/cf039f0ab84541778e6a31794fb76889
新 has the opposite meaning 'new'. Thus 구 and 신 are often used together as a single word '신구(新舊)' meaning old and new as in a phrase 新舊交代 (Exchange between the old and the new).