Nächste: Oktette und Werkzeuge für die Kryptographie, Vorige: Schriftzeichen, Nach oben: stringproc [Inhalt][Index]
Positionsindizes in Strings sind in Maxima genau so wie Listen 1-indiziert. Siehe hierzu das Beispiel in charat.
Gibt das n-te Schriftzeichen in string zurück. Das erste Zeichen in string erhält man mit n = 1.
Beispiel:
(%i1) charat("Lisp",1); (%o1) L (%i2) charlist("Lisp")[1]; (%o2) L
Gibt eine Liste mit allen Schriftzeichen in string zurück.
Beispiel:
(%i1) charlist("Lisp"); (%o1) [L, i, s, p]
Parse the string str as a Maxima expression and evaluate it. The string
str may or may not have a terminator (dollar sign $
or semicolon
;
). Only the first expression is parsed and evaluated, if there is more
than one.
Complain if str is not a string.
See also parse_string.
Examples:
(%i1) eval_string ("foo: 42; bar: foo^2 + baz"); (%o1) 42 (%i2) eval_string ("(foo: 42, bar: foo^2 + baz)"); (%o2) baz + 1764
Parse the string str as a Maxima expression (do not evaluate it). The
string str may or may not have a terminator (dollar sign $
or
semicolon ;
). Only the first expression is parsed, if there is more
than one.
Complain if str is not a string.
See also eval_string.
Examples:
(%i1) parse_string ("foo: 42; bar: foo^2 + baz"); (%o1) foo : 42 (%i2) parse_string ("(foo: 42, bar: foo^2 + baz)"); 2 (%o2) (foo : 42, bar : foo + baz)
Gibt eine Kopie der Zeichenkette string als neue Zeichenkette zurück.
Arbeitet wie supcase, jedoch werden Groß- in Kleinbuchstaben umgewandelt.
Gibt true
zurück, wenn string_1 und string_2 die selbe
Zeichensequenz enthalten.
Arbeitet wie sequal, ignoriert jedoch die Groß- und Kleinschreibung, was für Nicht-US-ASCII-Zeichen nur möglich ist, wenn das unter Maxima liegende Lisp einen Buchstaben auch als Buchstaben eines Alphabets erkennen kann. Siehe hierzu die Bemerkungen zu alphacharp.
simplode
takes a list of expressions and concatenates them into a string.
If no delimiter delim is specified, simplode
uses no delimiter.
delim can be any string.
Examples:
(%i1) simplode(["xx[",3,"]:",expand((x+y)^3)]); (%o1) xx[3]:y^3+3*x*y^2+3*x^2*y+x^3 (%i2) simplode( sexplode("stars")," * " ); (%o2) s * t * a * r * s (%i3) simplode( ["One","more","coffee."]," " ); (%o3) One more coffee.
Returns a string that is a concatenation of substring (string,
1, pos - 1)
, the string seq and substring (string,
pos)
. Note that the first character in string is in position 1.
Examples:
(%i1) s: "A submarine."$ (%i2) concat( substring(s,1,3),"yellow ",substring(s,3) ); (%o2) A yellow submarine. (%i3) sinsert("hollow ",s,3); (%o3) A hollow submarine.
Returns string except that each character from position start to end is inverted. If end is not given, all characters from start to the end of string are replaced.
Examples:
(%i1) sinvertcase("sInvertCase"); (%o1) SiNVERTcASE
Gibt die Anzahl der Zeichen in der Zeichenkette string zurück.
Gibt eine neue Zeichenkette mit num Zeichen char zurück.
Beispiel:
(%i1) smake(3,"w"); (%o1) www
Returns the position of the first character of string_1 at which
string_1 and string_2 differ or false
. Default test function
for matching is sequal. If smismatch
should ignore case, use
sequalignore as test.
Example:
(%i1) smismatch("seven","seventh"); (%o1) 6
Returns the list of all tokens in string.
Each token is an unparsed string.
split
uses delim as delimiter.
If delim is not given, the space character is the default delimiter.
multiple is a boolean variable with true
by default.
Multiple delimiters are read as one.
This is useful if tabs are saved as multiple space characters.
If multiple is set to false
, each delimiter is noted.
Examples:
(%i1) split("1.2 2.3 3.4 4.5"); (%o1) [1.2, 2.3, 3.4, 4.5] (%i2) split("first;;third;fourth",";",false); (%o2) [first, , third, fourth]
Returns the position of the first character in string which matches char. The first character in string is in position 1. For matching characters ignoring case see ssearch.
Returns a string like string but without all substrings matching
seq. Default test function for matching is sequal.
If sremove
should ignore case while searching for seq,
use sequalignore as test. Use start and end to limit searching.
Note that the first character in string is in position 1.
Examples:
(%i1) sremove("n't","I don't like coffee."); (%o1) I do like coffee. (%i2) sremove ("DO ",%,'sequalignore); (%o2) I like coffee.
Like sremove
except that only the first substring that matches seq
is removed.
Gibt eine Zeichenkette mit allen Zeichen von string in umgekehrter Reihenfolge zurück.
Returns the position of the first substring of string that matches the
string seq. Default test function for matching is sequal.
If ssearch
should ignore case, use sequalignore as test.
Use start and end to limit searching. Note that the first character in
string is in position 1.
(%i1) ssearch("~s","~{~S ~}~%",'sequalignore); (%o1) 4
Returns a string that contains all characters from string in an order such
there are no two successive characters c and d such that
test (c, d)
is false
and test (d,
c)
is true
. Default test function for sorting is
clessp. The set of test functions is
{clessp, clesspignore, cgreaterp, cgreaterpignore, cequal, cequalignore}
.
(%i1) ssort("I don't like Mondays."); (%o1) '.IMaddeiklnnoosty (%i2) ssort("I don't like Mondays.",'cgreaterpignore); (%o2) ytsoonnMlkIiedda.'
Returns a string like string except that all substrings matching old
are replaced by new. old and new need not to be of the same
length. Default test function for matching is sequal. If
ssubst
should ignore case while searching for old, use
sequalignore as test. Use start and end to limit searching.
Note that the first character in string is in position 1.
(%i1) ssubst("like","hate","I hate Thai food. I hate green tea."); (%o1) I like Thai food. I like green tea. (%i2) ssubst("Indian","thai",%,'sequalignore,8,12); (%o2) I like Indian food. I like green tea.
Like subst except that only the first substring that matches old is replaced.
Returns a string like string, but with all characters that appear in seq removed from both ends.
(%i1) "/* comment */"$ (%i2) strim(" /*",%); (%o2) comment (%i3) slength(%); (%o3) 7
Gibt true
zurück, wenn obj eine Zeichenkette ist.
Beispiel: Siehe Einführung.
Returns the substring of string beginning at position start and ending at position end. The character at position end is not included. If end is not given, the substring contains the rest of the string. Note that the first character in string is in position 1.
(%i1) substring("substring",4); (%o1) string (%i2) substring(%,4,6); (%o2) in
Returns string except that lowercase characters from position start to end are replaced by the corresponding uppercase ones. If end is not given, all lowercase characters from start to the end of string are replaced.
(%i1) supcase("english",1,2); (%o1) English
Returns a list of tokens, which have been extracted from string.
The tokens are substrings whose characters satisfy a certain test function.
If test is not given, constituent is used as the default test.
{constituent, alphacharp, digitcharp, lowercasep, uppercasep, charp, characterp, alphanumericp}
is the set of test functions.
(The Lisp-version of tokens
is written by Paul Graham. ANSI Common Lisp, 1996, page 67.)
(%i1) tokens("24 October 2005"); (%o1) [24, October, 2005] (%i2) tokens("05-10-24",'digitcharp); (%o2) [05, 10, 24] (%i3) map(parse_string,%); (%o3) [5, 10, 24]
Nächste: Oktette und Werkzeuge für die Kryptographie, Vorige: Schriftzeichen, Nach oben: stringproc [Inhalt][Index]