I want to have long texts without spaces written in monospace font (using \texttt). As line feeds don't appear automatically, I found this answer: https://tex.stackexchange.com/a/315376, where a macro is suggested.
As I want the text to break at several different symbols, I tried to change the macro to accept a parameter with the sign to break at. Unfortunately, this doesn't work properly, as you can see in the screenshot below.
Here is my version of the macro:
\documentclass{article}
\newcommand*\ttcomma[1]{\texttt{\expandafter\dottvar{\detokenize{#1}}{,}\relax}}
\newcommand*\dottvar[2]{%
\ifx\relax#1\else%
\expandafter%
\ifx\string#2#1%
\string#2\allowbreak%
\else#1
\fi
\expandafter\dottvar\fi
}
\begin{document}
Some normal Text \ttcomma{someLongTextWithoutSpacesButWithCommas,WhereIWantToGetALineFeedAndBreakToTheNextLine}
\end{document}
Where did I go wrong? Bonus question: How can I change the macro to do a line break at several different signs (e. g. ,, :, -)


