function format_number_choice(text_string, replace_hash, number) {
  pattern = new RegExp("\\\["+number+"\\\]\\\s?([^\|]*)");

  function replace_in_string(text_string, replace_hash) {
    for(var i in replace_hash)
     text_string = text_string.replace(new RegExp(i), replace_hash[i]);
    return text_string;
  }

  matches=text_string.match(pattern);

  if(matches != null)
    return replace_in_string(matches[1], replace_hash);
  else {
    pattern = /\[else\]\s?([^\|]*)/;
    matches=text_string.match(pattern);
    if(matches != null)
      return replace_in_string(matches[1], replace_hash);
    else
      return "not found";
  }
}