# regexpatch \xpatchcmd fails in patching command begins with space

The \xpatchcmd provided by regexpatch fails in patching command which begins with space. The same \xpatchcmd provided by xpatch works alright.

Some version info:

XeTeX      3.14159265-2.6-0.99999
expl3      2018/06/14
xparse     2018/05/12
regexpatch 2018/05/02 v0.2d


Example:

\documentclass{minimal}
\usepackage{regexpatch}

\def\test{source}
\xpatchcmd{\test}{source}{substituted}{}{\ddt}

% only this one fails
\def\test{ source}
\xpatchcmd{\test}{source}{substituted}{}{\ddt}

\def\test{source source}
\xpatchcmd{\test}{source}{substituted}{}{\ddt}

\begin{document}
abc
\end{document}


Note: This question ought to have tag "regexpatch", but currently I don't have enough reputation to create a new tag.

• Also commands that end with spaces. Not sure whether I'll fix this. – egreg Jul 9 '18 at 5:50