const regex = /(#EXTM3U\s+|#EXTINF:\d+,|(.*\.\w{3,4}).*\s+)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(#EXTM3U\\s+|#EXTINF:\\d+,|(.*\\.\\w{3,4}).*\\s+)', 'g')
const str = `#EXTM3U
#EXTINF:419,Alice in Chains - Rotten Apple
http://192.168.101.22:80/movies/9975.mkv
#EXTINF:260,Alice in Chains - Nutshell
http://192.168.101.22:80/movies/1254.mkv
#EXTINF:255,Alice in Chains - I Stay Away
http://192.168.101.22:80/movies/1254.mkv
#EXTINF:256,Alice in Chains - No Excuses
Alice in Chains_Jar of Flies_04_No Excuses.mp3
#EXTINF:157,Alice in Chains - Whale And Wasp
Alice in Chains_Jar of Flies_05_Whale And Wasp.mp3
#EXTINF:263,Alice in Chains - Don't Follow
Alice in Chains_Jar of Flies_06_Don't Follow.mp3
#EXTINF:245,Alice in Chains - Swing On This
Alice in Chains_Jar of Flies_07_Swing On This.mp3
`;
const subst = ``;
// 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