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