

    \filetitle{dbsearchuserdata}{Search database to find tseries by matching the content of their userdata fields}{dbase/dbsearchuserdata}

	\paragraph{Syntax}

\begin{verbatim}
[List,SubD] = dbsearchuserdata(D,Field1,Regexp1,Field2,Regexp2,...)
[List,SubD] = dbsearchuserdata(D,Flag,Field1,Regexp1,Field2,Regexp2,...)
\end{verbatim}

\paragraph{Input arguments}

\begin{itemize}
\item
  \texttt{D} {[} struct {]} - Input database whose tseries fields will
  be searched.
\item
  \texttt{Flag} {[} \texttt{'-all'} \textbar{} \texttt{'-any'} {]} -
  Specifies if all conditions or any condition must be met for the
  series to pass the test; if not specified, \texttt{'-all'} is assumed.
\item
  \texttt{Field1}, \texttt{Field2}, \ldots{} {[} char {]} - Names of
  fields in the userdata struct.
\item
  \texttt{Regexp1}, \texttt{Regexp2}, \ldots{} {[} char {]} - Regular
  expressions against which the respective userdata fields will be
  matched.
\end{itemize}

\paragraph{Output arguments}

\begin{itemize}
\item
  \texttt{List} {[} cellstr {]} - Names of tseries that pass the test.
\item
  \texttt{Subd} {[} struct {]} - Sub-database with only those tseries
  that pass the test.
\end{itemize}

\paragraph{Description}

For a successful match, the userdata must be a struct, and the tested
fields must be text strings.

Use an equal sign, \texttt{=}, after the name of the userdata fields in
\texttt{Field1}, \texttt{Field2}, etc. to request a case-insensitive
match, and an equal-shart sign, \texttt{=\#}, to indiciate a
case-sensitive match.

\paragraph{Example}

\begin{verbatim}
[list,dd] = dbsearchuserdata(d,'.DESC=','Exchange rate','.SOURCE=#','IMF');
\end{verbatim}

Each individual tseries object in the database \texttt{D} will be tested
for two conditions:

\begin{itemize}
\item
  whether its user data is a struct including a field named
  \texttt{DESC}, and the field contains a string
  \texttt{'Exchange rate'} in it (case insensitive, e.g.
  \texttt{'eXcHaNgE rAtE'} will also be matched);
\item
  whether its user data is a struct including a field named
  \texttt{SOURCE}, and the field contains a string \texttt{'IMF'} in it
  (case sensitive, e.g. \texttt{'Imf'} will not be matched).
\end{itemize}

All tseries object that pass both of these conditions are returned in
the \texttt{List} and the output database \texttt{D}.


