String( obj ) A
String( obj, length ) O
String returns a representation of obj,
which may be an object of arbitrary type, as a string.
This string should approximate as closely as possible the character
sequence you see if you print obj.
If length is given it must be an integer. The absolute value gives the minimal length of the result. If the string representation of obj takes less than that many characters it is filled with blanks. If length is positive it is filled on the left, if length is negative it is filled on the right.
In the two argument case, the string returned is a new mutable
string (in particular not a part of any other object);
it can be modified safely,
and MakeImmutable may be safely applied to it.
gap> String(123);String([1,2,3]); "123" "[ 1, 2, 3 ]"
StringPP( int ) F
returns a string representing the prime factor decomposition of the integer int.
gap> StringPP(40320); "2^7*3^2*5*7"
WordAlp( alpha, nr ) F
returns a string that is the nr-th word over the alphabet list
alpha, w.r.t. word length and lexicographical order.
The empty word is WordAlp( alpha, 0 ).
gap> List([0..5],i->WordAlp("abc",i));
[ "", "a", "b", "c", "aa", "ab" ]
LowercaseString( string ) F
returns a lowercase version of the string string, that is, a string in which each uppercase alphabet character is replaced by the corresponding lowercase character.
gap> LowercaseString("This Is UpperCase");
"this is uppercase"
SplitString( string, seps[, wspace] ) O
This function accepts a string string and lists seps and, optionally, wspace of characters. Now string is split into substrings at each occurrence of a character in seps or wspace. The characters in wspace are interpreted as white space characters. Substrings of characters in wspace are treated as one white space character and they are ignored at the beginning and end of a string.
Both arguments seps and wspace can be single characters.
Each string in the resulting list of substring does not contain any characters in seps or wspace.
A character that occurs both in seps and wspace is treated as a white space character.
A separator at the end of a string is interpreted as a terminator; in this case, the separator does not produce a trailing empty string.
gap> SplitString( "substr1:substr2::substr4", ":" ); [ "substr1", "substr2", "", "substr4" ] gap> SplitString( "a;b;c;d;", ";" ); [ "a", "b", "c", "d" ] gap> SplitString( "/home//user//dir/", "", "/" ); [ "home", "user", "dir" ]
ReplacedString( string, old, new ) F
replaces occurrences of the string old in string by new, starting from the left and always replacing the first occurrence. To avoid inifinite recursion, characters which have been replaced already, are not subject to renewed replacement.
gap> ReplacedString("abacab","a","zl");
"zlbzlczlb"
gap> ReplacedString("ababa", "aba","c");
"cba"
gap> ReplacedString("abacab","a","ba");
"babbacbab"
For the possibility to print GAP objects to strings, see String Streams.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual