const regex = /((http(s)?|ftp)?:\/\/|www\.)dc([0-9])+\.4shared\.com\/([a-z0-9\/@#$,%*_-])+\.?(mp3|mp4|pdf|txt|doc|pps|epub|png|gif|jpg|jpeg|3gp|avi|mpg|wmv|mov|mkv|apk)?/i;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('((http(s)?|ftp)?:\\\/\\\/|www\\.)dc([0-9])+\\.4shared\\.com\\\/([a-z0-9\\\/@#$,%*_-])+\\.?(mp3|mp4|pdf|txt|doc|pps|epub|png|gif|jpg|jpeg|3gp|avi|mpg|wmv|mov|mkv|apk)?', 'i')
const str = `http://dc778.4shared.com/img/4wW4UT5jba/9f90279b/dlink__2Fdownload_2F4wW4UT5jba_3Ftsid_3D20150615-114008-b7f2dbf8_26lgfp_3D1000_26sbsr_3D7c546ac8da497fae73b10095dc49e8d24e610417724fcf65/preview.wmv
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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