# xpatchcmd with placeholders

Is there an alternative to \xpatchcmd from the xpatch package which supports placeholders as in this virtual example:

\newcommand{\mycommand}{this is important \foo this is not \bar but this is}
\xpatchcmd{\mycommand}{\foo .* \bar}{}{}{}


The aim is to achieve the same as

\newcommand{\mycommand}{this is important but this is}


No, it's not possible with xpatch, but it is with the (experimental) regexpatch package:

\documentclass{article}
\usepackage{regexpatch}

\newcommand{\mycommand}{this is important \foo this is not \bar but this is}

\regexpatchcmd{\mycommand}{\c{foo} .* \c{bar}}{}{}{}

\begin{document}

\mycommand

\texttt{\meaning\mycommand}

\end{document}


Note that control sequences in the search regular expression must be denoted by \c{<cs-name>} as in the example.