Re: Getting Upper Case Letters from a Text String

Radhakrishnan CV <[email protected]>
Newsgroups gmane.comp.tex.tugindia
Message-ID <[email protected]>
On Thu, Jun 9, 2011 at 2:00 PM, Jitender Singh <[email protected]> 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
_______________________________________________
Home:        http://www.tug.org.in/
TeX FAQ:     http://www.tex.ac.uk/faq
unsubscribe: http://tug.org/mailman/listinfo/tugindia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.