function parser(txt){ regex = [txt.matchAll(/\[([^\]]+)\]\(([^)]+)\)/g),/(https?:\/\/[^\s]+)/g] for (const match of regex[0]) { if(!regex[1].test(match[2].trim())){url=`https://${match[2].trim()}`}else{url = match[2].trim()} txt = txt.replace(match[0],`${match[1].trim()}`) } return txt }