manipulating_strings/quickref.tex
author Anoop Jacob Thomas<anoop@fossee.in>
Sat, 18 Dec 2010 12:54:49 +0530
changeset 524 b602b4dcc87d
parent 523 54bdda4aefa5
permissions -rw-r--r--
Made some changes to the script embellishing a plot, but it still needs changes.

\textbf{Manipulating strings}

String indexing starts from 0, like lists.

\lstinline|s = `Hello World'|\\
\lstinline|s[0:5]| gives \texttt{Hello}\\
\lstinline|s[6:]| gives \texttt{World}\\
\lstinline|s[6::2]| gives \texttt{Wrd}\\

\lstinline|s.replace('e', 'a')| returns a new string with all e's
replaced by a.  

\lstinline|s.lower()| and \lstinline|s.upper()| return new strings
with all lower and upper case letters, respectively.