diff --git a/strings.html b/strings.html index 9c0fd70..ebd7129 100644 --- a/strings.html +++ b/strings.html @@ -156,6 +156,6 @@ -

Strings

These methods are available on both regular and Unicode strings.
.capitalize()
Important: For regular strings, this method depends on the currently configured locale to decide what is 'lowercase' and what is 'uppercase'.
Returns a copy of the string with the first character capitalized, and the rest of the characters lowercased.
.center(width[, fillchar])
Returns a copy of the string, centered by padding it with the fill character on both sides until the given width is reached.
width
The desired width of the final string.
fillchar
Optional. The character to use as a fill character. This is a space character by default.
.count(sub[, start[, end]])
Returns the number of non-overlapping occurrences of the given substring in the given range.
sub
The substring to search for.
start
Optional. The starting point for the search. Interpreted as in slice notation. Defaults to the start of the string.
end
Optional. The end point for the search. Interpreted as in slice notation. Defaults to the end of the string.
.decode([encoding[, errors]])
Returns a unicode string containing a copy of the original string, decoded using the codec registered for the specified encoding.
Since Python 2.7: You can also specify the arguments to this method as keyword arguments, for clarity.
encoding
Optional. The encoding that the string is currently in. If not specified, the value from sys.getdefaultencoding is used.
errors
Optional. The error handling scheme to use. Can be any of the following values, or any other name that is registered through codecs.register_error.
strict
This is the default. Encoding errors raise a UnicodeError exception, or a subclass thereof.
ignore
When an error is encountered, ignore the character, and move on to the next one.
replace
When an error is encountered, replace the problematic character with U+FFFD, for the built-in Unicode codecs.
.encode([encoding[, errors]])
Returns a regular string containing a copy of the original string, encoded using the codec registered for the specified encoding.
Since Python 2.7: You can also specify the arguments to this method as keyword arguments, for clarity.
encoding
Optional. The encoding you wish to encode the string to. If not specified, the value from sys.getdefaultencoding is used.
errors
Optional. The error handling scheme to use. Can be any of the following values, or any other name that is registered through codecs.register_error.
strict
This is the default. Encoding errors raise a UnicodeError exception, or a subclass thereof.
ignore
When an error is encountered, ignore the character, and move on to the next one.
replace
When an error is encountered, replace the problematic character with U+FFFD, for the built-in Unicode codecs.
xmlcharrefreplace
When an error is encountered, replace the problematic character with the corresponding XML entity.
backslashreplace
When an error is encountered, replace the problematic character with the corresponding backslashed escape sequence.
.endswith(suffix[, start[, end]])
Returns a boolean, indicating whether the string ends with the given suffix or not.
suffix
The suffix to check for. You can either specify a single string, or a tuple of strings to look for.
start
Optional. The starting point for the search. Interpreted as in slice notation. Defaults to the start of the string.
end
Optional. The end point for the search. Interpreted as in slice notation. Defaults to the end of the string.
.expandtabs([tabsize])
Returns a copy of the string, with all tab characters replaced by one or more spaces, depending on the specified tabsize.
The string is divided up into columns, each of which is as wide as the given tabsize. After every part of the string that is not a tab character, the current column is filled up with one or more spaces, until the next column 'border' is reached. If there are multiple tab characters in a row, the remaining tab characters will fill up an entire column.
Important: Every character that is not a tab, newline or return, will be treated as being one position wide, even if they are not displayed when printing the entire string.
tabsize
Optional. The amount of spaces that a tab character should be replaced with, at most. Defaults to 8.
+

Strings

These methods are available on both regular and Unicode strings.
.capitalize()
Important: For regular strings, this method depends on the currently configured locale to decide what is 'lowercase' and what is 'uppercase'.
Returns a copy of the string with the first character capitalized, and the rest of the characters lowercased.
.center(width[, fillchar])
Returns a copy of the string, centered by padding it with the fill character on both sides until the given width is reached.
width
The desired width of the final string.
fillchar
Optional. The character to use as a fill character. This is a space character by default.
.count(sub[, start[, end]])
Returns the number of non-overlapping occurrences of the given substring in the given range.
sub
The substring to search for.
start
Optional. The starting point for the search. Interpreted as in slice notation. Defaults to the start of the string.
end
Optional. The end point for the search. Interpreted as in slice notation. Defaults to the end of the string.
.decode([encoding[, errors]])
Returns a unicode string containing a copy of the original string, decoded using the codec registered for the specified encoding.
Since Python 2.7: You can also specify the arguments to this method as keyword arguments, for clarity.
encoding
Optional. The encoding that the string is currently in. If not specified, the value from sys.getdefaultencoding is used.
errors
Optional. The error handling scheme to use. Can be any of the following values, or any other name that is registered through codecs.register_error.
strict
This is the default. Encoding errors raise a UnicodeError exception, or a subclass thereof.
ignore
When an error is encountered, ignore the character, and move on to the next one.
replace
When an error is encountered, replace the problematic character with U+FFFD, for the built-in Unicode codecs.
.encode([encoding[, errors]])
Returns a regular string containing a copy of the original string, encoded using the codec registered for the specified encoding.
Since Python 2.7: You can also specify the arguments to this method as keyword arguments, for clarity.
encoding
Optional. The encoding you wish to encode the string to. If not specified, the value from sys.getdefaultencoding is used.
errors
Optional. The error handling scheme to use. Can be any of the following values, or any other name that is registered through codecs.register_error.
strict
This is the default. Encoding errors raise a UnicodeError exception, or a subclass thereof.
ignore
When an error is encountered, ignore the character, and move on to the next one.
replace
When an error is encountered, replace the problematic character with U+FFFD, for the built-in Unicode codecs.
xmlcharrefreplace
When an error is encountered, replace the problematic character with the corresponding XML entity.
backslashreplace
When an error is encountered, replace the problematic character with the corresponding backslashed escape sequence.
.endswith(suffix[, start[, end]])
Returns a boolean, indicating whether the string ends with the given suffix or not.
suffix
The suffix to check for. You can either specify a single string, or a tuple of strings to look for.
start
Optional. The starting point for the search. Interpreted as in slice notation. Defaults to the start of the string.
end
Optional. The end point for the search. Interpreted as in slice notation. Defaults to the end of the string.
.expandtabs([tabsize])
Returns a copy of the string, with all tab characters replaced by one or more spaces, depending on the specified tabsize.
The string is divided up into columns, each of which is as wide as the given tabsize. After every part of the string that is not a tab character, the current column is filled up with one or more spaces, until the next column 'border' is reached. If there are multiple tab characters in a row, the remaining tab characters will fill up an entire column each.
Important: Every character that is not a tab, newline or return, will be treated as being one position wide, even if they are not displayed when printing the entire string.
tabsize
Optional. The amount of spaces that a tab character should be replaced with, at most. Defaults to 8.
.find(sub[, start[, end]])
Returns the first position in the string where the given substring is found. If the substring is not found, the value -1 is returned.
sub
The substring to search for.
start
Optional. The starting point for the search. Interpreted as in slice notation. Defaults to the start of the string.
end
Optional. The end point for the search. Interpreted as in slice notation. Defaults to the end of the string.
diff --git a/strings.zpy b/strings.zpy index 4d999d3..d2fd94f 100644 --- a/strings.zpy +++ b/strings.zpy @@ -142,7 +142,7 @@ These methods are available on both regular and Unicode strings. a tab character, the current column is filled up with one or more spaces, until the next column 'border' is reached. If there are multiple tab characters in a row, the remaining tab - characters will fill up an entire column. + characters will fill up an entire column each. ! Every character that is not a tab, newline or return, will be treated as being one position wide, even if they are not @@ -151,3 +151,21 @@ These methods are available on both regular and Unicode strings. tabsize:: **Optional.** The amount of spaces that a tab character should be replaced with, at most. Defaults to 8. + +^ .find(`sub`[, `start`[, `end`]]) + + Returns the first position in the string where the given + substring is found. If the substring is not found, the value + `-1` is returned. + + sub:: + The substring to search for. + + start:: + **Optional.** The starting point for the search. + Interpreted as in slice notation. Defaults to the start + of the string. + + end:: + **Optional.** The end point for the search. Interpreted + as in slice notation. Defaults to the end of the string.