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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
522
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
\textbf{Manipulating strings}
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     2
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
String indexing starts from 0, like lists.
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     5
\lstinline|s = `Hello World'|\\
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
\lstinline|s[0:5]| gives \texttt{Hello}\\
523
54bdda4aefa5 Renamed some LOs and other minor corrections.
Puneeth Chaganti <punchagan@fossee.in>
parents: 522
diff changeset
     7
\lstinline|s[6:]| gives \texttt{World}\\
54bdda4aefa5 Renamed some LOs and other minor corrections.
Puneeth Chaganti <punchagan@fossee.in>
parents: 522
diff changeset
     8
\lstinline|s[6::2]| gives \texttt{Wrd}\\
522
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
\lstinline|s.replace('e', 'a')| returns a new string with all e's
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
replaced by a.  
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    13
\lstinline|s.lower()| and \lstinline|s.upper()| return new strings
d33698326409 Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    14
with all lower and upper case letters, respectively.