http://www.perlmonks.org?node_id=999820


in reply to Cleaning up directory paths, from strings containing multiple instances of directory path+filename

use warnings; use strict; use File::Basename; my $str = 'with arguments [/C move /Y "E:/Atlas/12_4_0_US/AppImage/Bin +/Installed Providers/VehicleRecords/VehicleRecordUpdateUtility.exe" " +E:/Atlas/12_4_0_US/EngPublish"]'; $str =~ s/"(.*?)"/'"' . basename($1) . '"'/eg; print "$str\n"; __END__ with arguments [/C move /Y "VehicleRecordUpdateUtility.exe" "EngPublis +h"]