use strict;
my $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 ';
my $regex = qr/^(\d+,\s*'[^',]*).*(',[^,\n]*)$/mp;
my $subst = '\\1\\2';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
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 Perl, please visit: http://perldoc.perl.org/perlre.html