def urlargs_replace_text_in_arg(urlargs, regexp_argname, text_old, text_new):
out = "<STR_LIT>"<EOL>urlargsdict = parse_qs(urlargs)<EOL>urlargsdictnew = {}<EOL>for key in urlargsdict.keys():<EOL><INDENT>if re.match(regexp_argname, key):  <EOL><INDENT>urlargsdictnew[key] = []<EOL>for parg in urlargsdict[key]:<EOL><INDENT>urlargsdictnew[key].append(parg.replace(text_old, text_new))<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>urlargsdictnew[key] = urlargsdict[key]<EOL><DEDENT><DEDENT>for key in urlargsdictnew.keys():<EOL><INDENT>for val in urlargsdictnew[key]:<EOL><INDENT>out += "<STR_LIT>" + key + "<STR_LIT:=>" + quote_plus(val, '<STR_LIT>')<EOL><DEDENT><DEDENT>if out.startswith("<STR_LIT>"):<EOL><INDENT>out = out[<NUM_LIT:5>:]<EOL><DEDENT>return out<EOL>
Analyze `urlargs' (URL CGI GET query arguments in string form)
       and for each occurrence of argument matching `regexp_argname'
       replace every substring `text_old' by `text_new'.  Return the
       resulting new URL.

       Used to be used for search engine's create_nearest_terms_box,
       now it is not used there anymore.  It is left here in case it
       will become possibly useful later.