Here'e the regex you want:
/(\/\/\/ cache ml\/\d\/\d{5}_..\.(png|jpg))+/i
/ is a special character so we have to escape it like this \/
cache ml\/3\/\ this part will match "cache ml\3\" exactly assuming its a stable
\d{5} will match any 5 digits
.. matches any 2 characters
. is a special character so we have to escape it like this \.
(png|jpg) will match png or jpg
- we group the whole thing in a group
() and use + this mean one or more so the regex will match any number of repetitions above one, not just 3 as your example
- we use
i at the end to make the regex case insensitive.
Now that we have the regex, we use it like this
var myString = "/// cache ml/\d/11204_gb.png/// cache ml/3/16917_ar.png/// cache ml/3/52871_au.jpg"
var myRegex = /(\/\/\/ cache ml\/3\/\d{5}_..\.(png|jpg))+/i
var newString = myString.replace(myRegex, "")
to make the matching more loss when it comes to filenames you can replace d{5}_.. with .* so the regex becomes:
/(\/\/\/ cache ml\/\d\/.*\.(png|jpg))+/i
this will natch any file name with png or jpg extension.