# Difference between regexpatch and xpatch

I'm trying to put individual names within my bibliographic entries into brackets, and trying to patch biblatex bibmacros for that, using the facilities of (rege)xpatch.

In particular, I'm trying to patch the bibmacros name:given-family and name:family-given.

As far as I understood, regexpatch offers the same patch commands xpatch does, plus some with regex features. And I couldn't grasp from the documentation any change of syntax of the original commands of xpatch whithin regexpatch. However, the patches which work with xpatch return undefined control sequence with regexpatch. A MWE:

\documentclass{article}

\usepackage{xpatch}
%\usepackage{regexpatch}

\usepackage[style=authortitle]{biblatex}

% These patches work with xpatch, but not with regexpatch
\xpatchbibmacro{name:given-family}
{\usebibmacro{name:hook}}
{\bibopenbracket\usebibmacro{name:hook}}
{}{}

\xapptobibmacro{name:given-family}
{\bibclosebracket}
{}{}

\xpatchbibmacro{name:family-given}
{\usebibmacro{name:hook}{#3#1}}
{\bibopenbracket\usebibmacro{name:hook}{#3#1}}
{}{}

\xpatchbibmacro{name:family-given}
{\usebibmacro{name:hook}{#1}}
{\bibopenbracket\usebibmacro{name:hook}{#1}}
{}{}

\xapptobibmacro{name:family-given}
{\bibclosebracket}
{}{}

\begin{document}

\nocite{*}

\printbibliography

\end{document}


What am I missing/doing wrong?

Obs: I need regexpatch for other patches that actually require the regex facilities, and I'd like to use the original xpatch patch commands, if possible, for the sake of code readability.

• A change in macro names that wasn't done at every place it was needed. A maintenance release should arrive soon. In the meantime, use \xpatchbibmacro* (changing all appearances should do nothing wrong in the shown cases). – egreg Jan 16 '18 at 12:40

You've discovered a hidden feature. ;-)

This should fix the temporary issue.

\documentclass{article}

%\usepackage{xpatch}
\usepackage{regexpatch}

% Fix regexpatch itself
\ExplSyntaxOn
\makeatletter
\exp_args:Nc \xpatchcmd { xpatchbibmacro~code }
{\xpatch_main:Ncnnnn}
{\xpatch_main_four:Ncnnnn}
{}{}
\makeatother
\ExplSyntaxOff

\usepackage[style=authortitle]{biblatex}

% These patches work with xpatch, but not with regexpatch
\xpatchbibmacro{name:given-family}
{\usebibmacro{name:hook}}
{\bibopenbracket\usebibmacro{name:hook}}
{}{}

\xapptobibmacro{name:given-family}
{\bibclosebracket}
{}{}

\xpatchbibmacro{name:family-given}
{\usebibmacro{name:hook}{#3#1}}
{\bibopenbracket\usebibmacro{name:hook}{#3#1}}
{}{}

\xpatchbibmacro{name:family-given}
{\usebibmacro{name:hook}{#1}}
{\bibopenbracket\usebibmacro{name:hook}{#1}}
{}{}

\xapptobibmacro{name:family-given}
{\bibclosebracket}
{}{}

\begin{document}

\nocite{*}

\printbibliography

\end{document}

• egreg, once you have your hands on it, I think it is no harm adding that regexpatch throws me Package l3regex Warning: This package is obsolete --- use 'expl3' instead. – gusbrs Jan 16 '18 at 13:11
• @gusbrs Yes, that's in the queue. – egreg Jan 16 '18 at 14:06