The idea is the same, but using more powerful expl3 methods.
With \link{<link>} you get the same as before, but with the possibility of breaking lines at slashes.
With \link*{<link>} you allow breaking at any letter. However this requires changing \textcolor{blue}{<string>} to \blue{<string>} otherwise also blue would be considered for breaking. Define similar commands for all colors you need and update the equivalences.
\documentclass[10pt]{article}
\usepackage{bookmark}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{xparse}
\NewDocumentCommand{\blue}{m}{\textcolor{blue}{#1}}
\ExplSyntaxOn
\NewDocumentCommand{\link}{sm}
{
\group_begin:
\cs_set_eq:NN \textbf \use:n
\cs_set_eq:NN \textit \use:n
\cs_set_eq:NN \blue \use:n
\cs_set:Npx \_ { \c_underscore_str }
\cs_set:Npx \& { \c_ampersand_str }
\tl_gset:Nx \g_tmpa_tl { #2 }
\group_end:
\tl_set:Nn \l_tmpa_tl { #2 }
\IfBooleanTF{#1}
{
\regex_replace_all:nnN { [A-Za-z] } { \0 \c{linebreak}[0] } \l_tmpa_tl
}
{
\tl_replace_all:Nnn \l_tmpa_tl { / } { /\linebreak[0] }
}
\group_begin:
\ttfamily
\exp_args:NVV \href \g_tmpa_tl \l_tmpa_tl
\group_end:
}
\ExplSyntaxOff
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{|>{\raggedright}X|l|}
\link{https://www.\blue{longlink}.com/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/} & Long link description\tabularnewline
\link*{www.\blue{longlinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglink}.net} & Long link description\tabularnewline
\end{tabularx}
\end{document}

It is also possible to adopt the “break everywhere” strategy when there is no slash:
\documentclass[10pt]{article}
\usepackage{bookmark}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{xparse}
\NewDocumentCommand{\blue}{m}{\textcolor{blue}{#1}}
\ExplSyntaxOn
\NewDocumentCommand{\link}{m}
{
\group_begin:
\cs_set_eq:NN \textbf \use:n
\cs_set_eq:NN \textit \use:n
\cs_set_eq:NN \blue \use:n
\cs_set:Npx \_ { \c_underscore_str }
\cs_set:Npx \& { \c_ampersand_str }
\tl_gset:Nx \g_tmpa_tl { #1 }
\group_end:
\tl_set:Nn \l_tmpa_tl { #1 }
\regex_match:nnTF { / } { #1 }
{
\tl_replace_all:Nnn \l_tmpa_tl { / } { /\linebreak[0] }
}
{
\regex_replace_all:nnN { [A-Za-z] } { \0 \c{linebreak}[0] } \l_tmpa_tl
}
\group_begin:
\ttfamily
\exp_args:NVV \href \g_tmpa_tl \l_tmpa_tl
\group_end:
}
\ExplSyntaxOff
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{|>{\raggedright}X|l|}
\link{https://www.\blue{example}.com/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/longlink/} & Long link description\tabularnewline
\link{www.\blue{longlinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglinklonglink}.net} & Long link description\tabularnewline
\end{tabularx}
\end{document}
The output is the same.
breakurlpackage withanythingbreaksoption)? – Marijn Jan 08 '19 at 21:32\usepackage[breaklinks=true]{hyperref}i get: Option clash for package hyperref, and\sloppydoesn't work. – BnG Jan 08 '19 at 21:37breaklinksoption for hyperref, it uses a separate package for breaking links (calledbreakurl). Did you try that? – Marijn Jan 08 '19 at 21:39\usepackage{breakurl}or\usepackage[anythingbreaks]{breakurl}don't work either. – BnG Jan 08 '19 at 21:41