up previous next
2.4.2 String Operations
CoCoA offers only a few operations on strings: length, concatenation, comparison, substring containment and indexing.

Example
/**/ str := "Hello" + "World!";  --> string concatenation
/**/ Print str;
HelloWorld!
/**/ len(str);       --> length in characters
11
/**/ "Abc" < str;    --> lexicographical comparison
true
/**/ str[1];         --> character indexing, indexes start from 1
H
The operator IsIn can be used to test if one string is a substring of another.

Example
/**/  mesg := "Banana";
/**/  "ana" IsIn mesg;
true
/**/  "Ana" IsIn mesg;  --> substring must be an exact match
false