JavaScript – Reduced Code, In Favor Of Silent Failing With Try/Catch

Avoiding large amount cases-handling (‘if’ conditions)
in a heuristic method, using try/catch.

function get_part(string, regex){  //first match.
  var text;
  text = string.match(regex)[1]

  if("undefined" === text) return undefined;
  text = decodeURIComponent(text);
  text = text.replace(/\&/g, "&");
  return text;

function fix_example(element){
  var REGEX = /instagram\.com\/[^\"\&]*u=([^\&]+)/i
     ,text  = element.href                              //full URL
  text = get_part(text, REGEX);
  if("undefined" === typeof text) return;
  element.setAttribute("href", text);