Page 1 of 1

Regex help

Posted: August 7th, 2009, 7:00 pm
by PiNPOiNT
I'm trying to tweak a greasemonkey script, and i'm having trouble with the regex of part of it, and wondered if anyone could help.

Here's the original

Code: Select all

this.getGenre = function(text, report) {
		var match = text.match(/Certification:[^<>]*([^]*?)(?=<\/div>)/);
		if(match) {
			genre = match[0].replace(/(<([^>]+)>)/ig,"").substring(7);
			genre = genre.replace("more", "");
			return genre;
		}
		return null;
	}
But the results of the info from the imdb page come up as

cation:
Iceland:16 | South Korea:15 | Argentina:16 | Australia:MA | Belgium:KT | Canada:13+ (Quebec) | Canada:14A (Alberta/British Columbia) | Canada:14 (Nova Scotia) | Canada:AA (Ontario) | Canada:PA (Manitoba) | Chile:14 | Finland:K-16 | France:U | Germany:12 | Hong Kong:IIB | Ireland:18 | Netherlands:16 | Portugal:M/16 | Singapore:M18 | Spain:13 | Sweden:15 | Switzerland:12 (canton of Geneva) | Switzerland:12 (canton of Vaud) | UK:15 | USA:R


Ideally, i'd like it to only show whatever is after USA: (in this example the letter "R")

Can someone help me with the code?  Thanks

Re: Regex help

Posted: August 10th, 2009, 11:52 pm
by TeraLove
PiNPOiNT wrote:I'm trying to tweak a greasemonkey script
How exactly have you connected Greasemonkey with SABnzbd+?

Re: Regex help

Posted: August 12th, 2009, 12:58 pm
by dorentuz
The most simple solution (but definitely not the fastest) is something like this placed before the return:

Code: Select all

genre = genre.replace("USA:([a-zA-Z0-9+-]+)");
Haven't tested it though, but something like that should work.. And if it doesn't, please post the entire script or at least the input of that function.