resized(n) returns a copy of the array, resized so that each element
is of length n characters. Extra characters are filled with value
fill. Caution: do not confuse this method with resize() which
changes the number of elements rather than the size of each element.
>>> c = str.array(["this","that","another"])
>>> c.itemsize()
7
>>> d = c.resized(20)
>>> print d
['this', 'that', 'another']
>>> d.itemsize()
20
concatenate(
other)
concatenate(other) returns a new array which corresponds to the
element by element concatenation of other to self. The
addition operator is also overloaded to perform concatenation.
sort modifies the CharArray inplace so that its elements are in
sorted order. sort only works for 1D character arrays. Like the
sort() for the Python list, CharArray.sort() returns nothing.
argsort returns a numarray corresponding to the permutation which will
put the character array self into sorted order. argsort only
works for 1D character arrays.
amap applies the function f to every element of self and
returns the nested list of the results. The function f should operate
on a single string and may return any Python value.
match uses Python regular expression matching over all elements of a
character array and returns a tuple of numarrays corresponding to the indices
of self where the pattern matches. flags are passed directly to
the Python pattern matcher defined in the re module of the standard
library.
search uses Python regular expression searching over all elements of a
character array and returns a tuple of numarrays corresponding to the indices
of self where the pattern was found. flags are passed directly
to the Python pattern search method defined in the re module of
the standard library. flags should be an or'ed combination (use the
operator) of the following re variables: IGNORECASE,
LOCALE, MULTILINE, DOTALL, VERBOSE. See the
re module documentation for more details.
sub(
pattern,replacement,flags=0,count=0)
sub performs Python regular expression pattern substitution
to all elements of a character array. flags and count work
as they do for re.sub().
grep is intended to be used interactively to search a CharArray
for the array of strings which match the given pattern.
pattern should be a Python regular expression (see the re
module in the Python standard library, which can be as simple as a string
constant as shown below.
eval executes the Python eval function on each element of a character
array and returns the resulting numarray. eval is intended for use
converting character arrays to the corresponding numeric arrays. An
exception is raised if any string element fails to evaluate.