Regex help

Come up with a useful post-processing script? Share it here!
Post Reply
PiNPOiNT

Regex help

Post 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
User avatar
TeraLove
Newbie
Newbie
Posts: 18
Joined: June 1st, 2008, 9:07 pm

Re: Regex help

Post by TeraLove »

PiNPOiNT wrote:I'm trying to tweak a greasemonkey script
How exactly have you connected Greasemonkey with SABnzbd+?
Last edited by TeraLove on August 10th, 2009, 11:58 pm, edited 1 time in total.
dorentuz
Newbie
Newbie
Posts: 5
Joined: May 6th, 2009, 4:51 pm

Re: Regex help

Post 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.
Post Reply