Find and replace text in bibentry using macros

I want to be able to display a bibliography entry but I want to highlight some part of it, specifically some author, but not all. So far I am able to create the bib entry in the middle of the text, and I am also able to do a find and replace of text (copied from here). However, when I try to do the find and replace the text of the bib entry it does not work.

Here is my example bib tex file:

\begin{filecontents}{mybib.bib}
{

@InProceedings{pcl,
author    = {Radu Bogdan Rusu and Steve Cousins},
title     = {{3D is here: Point Cloud Library (PCL)}},
booktitle = {{IEEE International Conference on Robotics and Automation (ICRA)}},
month     = {May 9-13},
year      = {2011},
}
@misc{opencv,
title={Open Source Computer Vision Library},
author={Itseez},
year={2015},
howpublished = {\url{https://github.com/itseez/opencv}}
}
@manual{opencv_manual,
title = {The OpenCV Reference Manual},
organization = {Itseez},
edition = {2.4.9.0},
month = {April},
year = {2014},
notes = {See \url{http://opencv.org/}}
}
}

\end{filecontents}

\documentclass{article}
\usepackage{natbib}
\usepackage{bibentry}
\usepackage{hyperref}
\usepackage{etoolbox}
\nobibliography*

% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\newcommand{\searchreplace}[3]{\patchcmd{#1}{#2}{#3}{}{}}
\newcommand{\bibelement}[1]
{
\begin{NoHyper}% In my real project I need the bibentry package to work with hyperref package.
\bibentry{#1}
\end{NoHyper}
}
\newcommand{\bibelementhighlight}[2]
{
%\searchreplace{\bibelement{#1}}{#2}{\textbf{#2}}
\newcommand{\auxbibliography}{\bibelement{#1}}
First time: \auxbibliography \\
\searchreplace{\auxbibliography}{#2}{\textbf{#2}}
Second time: \auxbibliography
}

\begin{document}

\newcommand{\afgfgft}{Rusu, R. B. and Cousins, S.}
\afgfgft \\
\searchreplace{\afgfgft}{Rusu, R. B.}{\textbf{Rusu, R. B.}}
\afgfgft

Here are some citations for articles: \cite{pcl} and \cite{opencv} and \bibelement{opencv_manual} and the one which I want to highlight:
\begin{itemize}
\item \bibelementhighlight{pcl}{Rusu}
\end{itemize}

\bibliographystyle{apalike}
\bibliography{mybib.bib}

\end{document}


When I compile this code I get the following (note that there is also added drawing and text explaining what I want to get):

where everything works fine except for the substitution of Rusu the second time the bibelement is displayed. After messing arround I think that this might be because \bibitem is expanded after the string replace. Can somebody give me a hint on how to solve it?

• I cannot get your MWE to compile. It says there is a runaway argument. – Steven B. Segletes Apr 12 '18 at 10:49
• I can compile this exact same code with [sharelatex](www.sharelatex.com) and in my computer using Ubungu 14.04 by doing pdflatex+bibtex+pdflatex. I do not know what your error is... – apalomer Apr 12 '18 at 10:53