You can use something like this:
var needle = 'blu';
var s = 'red; yellow; blue; geen; purple';
var a = s.split('; ');
var newArray = new Array();
for (var i = 0; i < a.length; i++) {
if (a[i].indexOf(needle) != -1) {
newArray.push(a[i]);
}
}
var result = newArray.join('; ');
alert(result);
The method is mainly described by Simon with one additional step - a joinat the end, to convert the result back to a string.
, . : , . , :
var s = 'red; yellow; blue; geen; purple';
var result = ('; ' + s).replace(/;(?![^;]*blu)[^;]*(?=;|$)/g, '').substring(2);
alert(result);