2013-03-06: Update:
It seems that there was a recent update to xstring which resolved this problem. Just updated all packages and the MWE below now correctly produces:

It seems as if I am having a problem understanding \StrGobbleRight. The intent of the the \RemoveTrailingSpace is to do what it says, that is remove trailing space on the right. But the MWE seems to be inserting space on the left:

This is part of a much bigger macro so I use \SearchTarget later on, but don't want this spacing???
Code:
\documentclass{article}
\usepackage{showframe}
\usepackage{xstring}
\newcommand*{\RemoveTrailingSpace}[1]{%
\IfEndWith{#1}{\space}{%
\StrGobbleRight{#1}{1}[\SearchTarget]%
}{%
\def\SearchTarget{#1}%
}%
\SearchTarget%
}
\begin{document}\noindent
X\RemoveTrailingSpace{YYY}Z
\noindent
X\RemoveTrailingSpace{ YYY}Z
\noindent
X\RemoveTrailingSpace{YYY }Z
\noindent
X\RemoveTrailingSpace{YYY }Z
\end{document}
\@cs@removefirstsyntaxunit, line 209f.: An opening brace at the end of the line. – Qrrbrbirlbel Mar 7 at 2:55