Copyright (C) 2000-2012 |
GNU Info (librep.info)StringsStrings ------- A string is a vector of characters (Note: Characters), they are generally used for storing and manipulating pieces of text. `librep' puts no restrictions on the values which may be stored in a string--specifically, the null character (`^@') may be stored with no problems. The read syntax of a string is a double quote character, followed by the contents of the string, the object is terminated by a second double quote character. For example, `"abc"' is the read syntax of the string `abc'. Any backslash characters in the string's read syntax introduce an escape sequence; one or more of the following characters are treated specially to produce the next _actual_ character in the string. The following escape sequences are supported (all are shown without their leading backslash `\' character). `n' A newline character. `r' A carriage return character. `f' A form feed character. `t' A TAB character. `a' A `bell' character (this is Ctrl-g). `\' A backslash character. `^C' The `control' code of the character C. This is calculated by toggling the seventh bit of the _upper-case_ version of C. For example, \^C ;A Ctrl-c character (ASCII value 3) \^@ ;The NUL character (ASCII value 0) `012' The character whose ASCII value is the octal value `012'. After the backslash character the Lisp reader reads up to three octal digits and combines them into one character. `x12' The character whose ASCII value is the hexadecimal value `12', i.e. an `x' character followed by one or two hex digits. - Function: stringp object This function returns true if its argument is a string. - Function: make-string length #!optional initial-character Creates a new string containing LENGTH characters, each character is initialised to INITIAL-CHARACTER (or to spaces if INITIAL-CHARACTER is not defined). (make-string 3) => " " (make-string 2 ?$) => "$$" - Function: concat #!rest args This function concatenates all of its arguments, ARGS, into a single string which is returned. If no arguments are given then the null string (`') results. Each of the ARGS may be a string, a character or a list or vector of characters. Characters are stored in strings modulo 256. (concat "foo" "bar") => "foobar" (concat "a" ?b) => "ab" (concat "foo" [?b ?a ?r]) => "foobar" (concat) => "" - Function: substring string start #!optional end This function creates a new string which is a partial copy of the string STRING. The first character copied is START characters from the beginning of the string. If the END argument is defined it is the index of the character to stop copying at, if it is not defined all characters until the end of the string are copied. (substring "xxyfoozwx" 3 6) => "foo" (substring "xyzfoobar" 3) => "foobar" - Function: string= string1 string2 This function compares the two strings STRING1 and STRING2--if they are made from the same characters in the same order then true is returned. (string= "one" "one") => t (string= "one" "two") => () Note that an alternate way to compare strings (or anything!) is to use the `equal' function. - Function: string-equal string1 string2 Returns true if STRING1 and STRING2 are the same, ignoring differences in character case. - Function: string< string1 string2 This function returns true if STRING1 is `less' than `string2'. This is determined by comparing the two strings a character at a time, the first pair of characters which do not match each other are then compared with a normal `less-than' function. In `librep' the standard `<' function understands strings so `string<' is just a macro calling that function. (string< "abc" "abd") => t (string< "abc" "abb") => () - Function: string-lessp string1 string2 Similar to `string<' but ignores character case in comparisons. See Note: String Functions for a few more string manipulating functions, and Note: Regular Expressions for a method of pattern matching in strings. automatically generated by info2www version 1.2.2.9 |