Next: Octets and Utilities for Cryptography, Previous: Characters, Up: stringproc [Contents][Index]
Position indices in strings are 1-indexed like in Maxima lists. See example in charat.
Returns the n-th character of string. The first character in string is returned with n = 1.
(%i1) charat("Lisp",1); (%o1) L (%i2) charlist("Lisp")[1]; (%o2) L
‘Category: Package stringproc’
Returns the list of all characters in string.
(%i1) charlist("Lisp"); (%o1) [L, i, s, p]
‘Category: Package stringproc’
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.
Examples:
(%i1) eval_string ("foo: 42; bar: foo^2 + baz"); (%o1) 42 (%i2) eval_string ("(foo: 42, bar: foo^2 + baz)"); (%o2) baz + 1764
See also parse_string.
‘Category: Package stringproc’
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.
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)
See also eval_string.
‘Category: Package stringproc’
Returns a copy of string as a new string.
‘Category: Package stringproc’
Like supcase but uppercase characters are converted to lowercase.
‘Category: Package stringproc’
Returns true
if string_1 and string_2 contain the same
sequence of characters.
‘Category: Predicate functions’ ‘Category: Package stringproc’
Like sequal
but ignores case which is only possible for non-US-ASCII
characters when the underlying Lisp is able to recognize a character as an
alphabetic character. See remarks on alphacharp.
‘Category: Predicate functions’ ‘Category: Package stringproc’
sexplode
is an alias for function charlist
.
‘Category: Package stringproc’
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.
See also concat
, sconcat
, string
and printf
.
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.
‘Category: Package stringproc’
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.
‘Category: Package stringproc’
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
‘Category: Package stringproc’
Returns the number of characters in string.
‘Category: Package stringproc’
Returns a new string with a number of num characters char.
Example:
(%i1) smake(3,"w"); (%o1) www
‘Category: Package stringproc’
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
‘Category: Package stringproc’
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]
‘Category: Package stringproc’
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.
‘Category: Package stringproc’
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.
‘Category: Package stringproc’
Like sremove
except that only the first substring that matches seq is removed.
‘Category: Package stringproc’
Returns a string with all the characters of string in reverse order.
See also reverse
.
‘Category: Package stringproc’
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.
Example:
(%i1) ssearch("~s","~{~S ~}~%",'sequalignore); (%o1) 4
‘Category: Package stringproc’
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}
.
Examples:
(%i1) ssort("I don't like Mondays."); (%o1) '.IMaddeiklnnoosty (%i2) ssort("I don't like Mondays.",'cgreaterpignore); (%o2) ytsoonnMlkIiedda.'
‘Category: Package stringproc’
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.
Examples:
(%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.
‘Category: Package stringproc’
Like subst
except that only the first substring that matches old is replaced.
‘Category: Package stringproc’
Returns a string like string, but with all characters that appear in seq removed from both ends.
Examples:
(%i1) "/* comment */"$ (%i2) strim(" /*",%); (%o2) comment (%i3) slength(%); (%o3) 7
‘Category: Package stringproc’
Like strim
except that only the left end of string is trimmed.
‘Category: Package stringproc’
Like strim
except that only the right end of string is trimmed.
‘Category: Package stringproc’
Returns true
if obj is a string.
See introduction for example.
‘Category: Predicate functions’ ‘Category: Package stringproc’
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.
Examples:
(%i1) substring("substring",4); (%o1) string (%i2) substring(%,4,6); (%o2) in
‘Category: Package stringproc’
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.
Example:
(%i1) supcase("english",1,2); (%o1) English
‘Category: Package stringproc’
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.)
Examples:
(%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]
‘Category: Package stringproc’
Next: Octets and Utilities for Cryptography, Previous: Characters, Up: stringproc [Contents][Index]