manipulating_strings/quickref.tex
author Puneeth Chaganti <punchagan@fossee.in>
Thu, 02 Dec 2010 14:43:42 +0530
changeset 523 54bdda4aefa5
parent 522 d33698326409
permissions -rw-r--r--
Renamed some LOs and other minor corrections.

\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.