manipulating-strings/quickref.tex
author Anoop Jacob Thomas<anoop@fossee.in>
Wed, 10 Nov 2010 21:17:33 +0530
changeset 449 471e1e5844a1
parent 285 7c4855fb8e5f
permissions -rw-r--r--
Added quickref to getting started with functions.

\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 \textt{World}\\
\lstinline|s[6::2]| gives \textt{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.