I need to break a url at both '_' and '-':
http://www.domain.org/word/word-word_(word-word)/.
Thanks to this thread, by using \RequirePackage[hyphens]{url} and \usepackage[hyphens]{url}, I get line break at '-', but it does not seem to work at '_'.
Your advise is welcome.
UPDATE
\RequirePackage[hyphens]{url}
\documentclass[a4paper,12pt]{article}
\usepackage[hyphens]{url}
\makeatletter
\def\do@url@hyp{\do\-\do\_}
\makeatother
\begin{document}
\url{http://www.dom.it/aaaa/word-word\_word-word\_word-word\_word-word\_word-word\_word-word\_word-word------------------------------------------------------------------------------------------------------------------(xyz)}
\url{http://www.dom.it/aaaa/word-word\_word-word\_word-word/word-word\_word-word\_word-word\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_(xyz)}
\end{document}
So, it seems that it works with '_', and it does not with many '-'. Your comment is welcome.


\_is different from_; if you try with__, you'll see that also this is only split after the last underscore, just like--. – egreg Jul 13 '16 at 22:02