public static int countOccurrences(String str, String sub)
	{
		//Remove occurrences and then check the new lengths.
		//Neat solution found on StackOverflow.
		if(sub.length() > 0)
		{
			return (str.length() - str.replace(sub, "").length()) / sub.length();
		}
		
		return 0;
	}