Index: src/ephy-location-action.c
===================================================================
--- src/ephy-location-action.c	(revision 7972)
+++ src/ephy-location-action.c	(working copy)
@@ -91,65 +91,12 @@ static guint signals[LAST_SIGNAL];
 
 G_DEFINE_TYPE (EphyLocationAction, ephy_location_action, EPHY_TYPE_LINK_ACTION)
 
-static const struct
-{
-	const char *prefix;
-	int len;
-}
-web_prefixes [] =
-{
-	{ "http://www.", 11 },
-	{ "http://ftp.", 11 },
-	{ "http://", 7 },
-	{ "https://www.", 12 },
-	{ "https://", 8 },
-	{ "ftp://", 6},
-	{ "ftp://ftp.", 10},
-	{ "www.", 4 },
-	{ "ftp.", 4}
-};
-
-
-static gboolean
-keyword_match (const char *list,
-	       const char *keyword)
-{
-	const char *p;
-	gsize keyword_len;
-
-	p = list;
-	keyword_len = strlen (keyword);
-
-	while (*p)
-	{
-		int i;
-
-		for (i = 0; i < keyword_len; i++)
-		{
-			if (p[i] != keyword[i])
-			{
-				goto next_token;
-			}
-		}
-	  
-		return TRUE;
-	  
-		next_token:
-
-		while (*p && !g_ascii_ispunct(*p) && !g_ascii_isspace(*p)) p++;
-		while (*p && (g_ascii_ispunct(*p) || g_ascii_isspace(*p))) p++;
-	}
-
-	return FALSE;
-}
-
 static gboolean
 completion_func (GtkEntryCompletion *completion,
 		 const char *key,
 		 GtkTreeIter *iter,
 		 gpointer data)
 {
-	int i, len_key, len_prefix;
 	char *item = NULL;
 	char *url = NULL;
 	char *keywords = NULL;
@@ -167,40 +114,15 @@ completion_func (GtkEntryCompletion *com
 			    EPHY_COMPLETION_URL_COL, &url,
 			    EPHY_COMPLETION_KEYWORDS_COL, &keywords,
 			    -1);
-
-	len_key = strlen (key);
-	if (!strncasecmp (key, item, len_key))
-	{
-		ret = TRUE;
-	}
-	else if (keyword_match (keywords, key))
-	{
-		ret = TRUE;
-	}
-	else if (!strncasecmp (key, url, len_key))
-	{
-		ret = TRUE;
-	}
-	else
-	{
-		for (i = 0; i < G_N_ELEMENTS (web_prefixes); i++)
-		{
-			len_prefix = web_prefixes[i].len;
-			if (!strncmp (web_prefixes[i].prefix, item, len_prefix) &&
-			    !strncasecmp (key, item + len_prefix, len_key))
-			{
-				ret = TRUE;
-				break;
-			}
-			else if (!strncmp (web_prefixes[i].prefix, url, len_prefix) &&
-			        !strncasecmp (key, url + len_prefix, len_key))
-			{
-				ret = TRUE;
-				break;
-			}
-
-		}
-	}
+	
+	if (!key)
+		return FALSE;
+	
+	ret = (g_regex_match_simple (key, item, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY)
+		|| g_regex_match_simple (key, url, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY)
+		|| g_regex_match_simple (key, keywords, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY)
+		);
+	
 	
 	gtk_tree_model_sort_convert_iter_to_child_iter 
 		(GTK_TREE_MODEL_SORT (model), &iter2, iter);
@@ -213,10 +135,6 @@ completion_func (GtkEntryCompletion *com
 	    (iter2.user_data2 == priv->history))
 		ret = FALSE;
 
-	g_free (item);
-	g_free (url);
-	g_free (keywords);
-
 	return ret;
 }
 
