Declan1991;1172107 wrote:As far as I know, there's no way to do it like that [...]
var arr = str.replace(/.*\-user\:(\w+)((\,\w+)*).*/i,"$1$2").split(",");
Yeah. After further googling I stumbled upon the term "atomic groups", which seems to be what I'm used to from other languages but isn't supported in js :~( So I solved my problem with String.split as you suggested. Thanks for your help!
/**
* Parse the user input for search parameters and store them in yt.searchParams.
* Known parameters are:
* -user:<user-1>,<user-2>,...,<user-20> limit search to videos uploaded by specific users
* @param {String} searchTerm User input containing the search term plus optional parameters
* @return {String} The search term without parameters
*/
yt.parseSearchTerm = function(searchTerm) {
var users = [];
function getSubmatches() {
users = getSubmatches.arguments[1].split(",");
return "";
}
searchTerm = searchTerm.replace(yt.searchParams.expr.USER_PARAM, getSubmatches);
yt.searchParams.users = users;
//!DEBUG:
for (var i = 0, field; field = yt.searchParams.users[i]; ++i) println("#" + i + ": " + field);
return searchTerm.trim();
}