const regex = /^(\d+,\s*'[^',]*).*(',[^,\n]*)$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^(\\d+,\\s*\'[^\',]*).*(\',[^,\\n]*)$', 'gm')
const str = `119, 'Youth Campus,Janakpur', Janakpur
978, 'Yog Kumar Janta Campus, Balwa-3', Mahottari
806, 'Yerawati Aadarsha Multiple Campus, Lalmatiya Deukhuri, Dang', Dang
613, 'Yasok Campus, Yasok, Panchther', Panchthar
458, 'Yagyodaya Dudhnath Tharu Multiple Campus,Suddhodhan-3,Ramawapur', Rupandehi
1008, 'Yagnyabhumi Multiple Campus, Dharapani', Dhanusha
546, 'Xavier International College, Kamalpokhari,kath', Kathmandu
362, 'Xavier Academy Science College, Lazimpat, Kathmandu', Kathmandu `;
const subst = `\1\2`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions