[Tugindia] Getting Upper Case Letters from a Text String

Radhakrishnan CV cvr at river-valley.org
Thu Jun 9 13:15:31 CEST 2011


On Thu, Jun 9, 2011 at 2:00 PM, Jitender Singh <jsinghdrdo at gmail.com> wrote:
> Hi TeXies,
> I need to process a text string to get upper case letters in it. To be
> specific, the newcommand \getUpperCase{Defence Research and Development
> Organization, Rajaji Marg Delhi}
> shall give DRDO i.e. uppercase letters before comma (,) in the argument
> string. Can somebody help me on this?

\documentclass{article}

\makeatletter
\def\getUpperCase#1{\@getUpperCase#1,\@nil}
\def\@getUpperCase#1,#2\@nil{\@tfor\mychar:=#1\do{%
       {\edef\@tmp{\noexpand`\mychar}%
        \ifnum\numexpr\sfcode\@tmp=999\relax
         \mychar\fi}}}
\makeatother

\begin{document}

\getUpperCase{Defence Research and Development
  Organization, Rajaji Marg Delhi 11223}

\end{document}

Best regards
-- 
Radhakrishnan


More information about the tugindia mailing list