/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println(a("http://e...content-available-to-author-only...e.com/", new String[] {"foo"}));
		System.out.println(a("http://e...content-available-to-author-only...e.com/?foo=bar", new String[] {}));
		System.out.println(a("http://e...content-available-to-author-only...e.com/", new String[] {}));
		System.out.println(a("http://e...content-available-to-author-only...e.com/?foo=1&bar=2&baz=3", new String[] {"foo", "baz"}));
		System.out.println(a("http://e...content-available-to-author-only...e.com/?foo=1&bar=2&baz=3", new String[] {"foo", "bar", "baz"}));
		System.out.println(a("http://e...content-available-to-author-only...e.com/?foo&bar=2&baz=", new String[] {"foo", "baz"}));
		System.out.println(a("http://e...content-available-to-author-only...e.com/?abc=1&def=2&baz=foo", new String[] {"foo", "bar"}));
		System.out.println(a("http://e...content-available-to-author-only...e.com/?foobar=baz", new String[] {"foo"}));
		System.out.println(a("http://foo:foo@foo.com:8080/?foo=1&bar=foo", new String[] {"foo"}));
	}
	
	static String a(String a,String[]b){for(String c:b)a=a.replaceAll("(?<=[?&])"+c+"(=[^&]*)?(&|$)","");return a.replaceAll("[?&]$","");}
}