Charles.Forsyth20060303-partialeea662d19 years agoHistory
177 lines · 3.6 KB · Text
RawDownload
.TH STRING 2.SH NAMEstring: append, drop, in, prefix, quoted, splitl, splitr, splitstrl,splitstrr, take, tobig, toint, tolower, toupper, unquoted \- string operations.SH SYNOPSIS.EXinclude "string.m";str := load String String->PATH; append:    fn(s: string, l: list of string): list of string;drop:      fn(s, cl: string): string;in:        fn(c: int, cl: string): int;prefix:    fn(pre, s: string): int;splitl:    fn(s, cl: string): (string, string);splitr:    fn(s, cl: string): (string, string);splitstrl: fn(s, t: string): (string, string);splitstrr: fn(s, t: string): (string, string);take:      fn(s, cl: string): string;tobig:     fn(s: string, base: int): (big, string);toint:     fn(s: string, base: int): (int, string);tolower:   fn(s: string): string;toupper:   fn(s: string): string;quoted:    fn(args: list of string): string;unquoted:  fn(s: string): list of string;.EE.SH DESCRIPTIONThe.I clargument to some of these functions is a character class in whicha.B -between any two characters indicates a range and a.B ^in the first position means.I not inthe class.Example of classes are.B \&"a-zA-Z"and.B\&"^acg-mr"\c\&..PP.B Appendappends string.I sto the end of string list.IR l ..PP.B Dropremoves the maximal prefix of string.I sthat is in class.IR cl ..PP.B Inreturns 1 ifcharacter.I cis in class.I cland 0 if it is not. .PP.B Prefixreturns 1 if string.I preis a prefix of string.I sand 0 if it is not..PP.B Splitlsplits string.I sjust before the first character in class.IR cl ..PP.B Splitrsplits string.I sjust after the last character in class.IR cl ..PP.B Splitstrlsplits string.I sjust before the leftmost segment of string.I sthat consists entirely of string.IR t ,and returns a tuple with the resulting pair of strings.If.I tdoes not occur in.IR s ,the result is.RI ( s , nil )..PP.B Splitstrrsplits string.I sjust after the rightmost segment of string.I sthat consists entirely of string.IR t ,and returns a tuple with the resulting pair of strings.If.I tdoes not occur in.IR s ,the result is.RI ( nil, s )..PP.B Takereturns the maximal prefix of string.I sthat is in class.IR cl ..PP.B Tointreturns as an integer the value represented by the string.IR s .The string is scanned up to the first character inconsistentwith.IR base .The first inconsistent character marks the beginning of thereturned string.Leading white-space characters are ignored.The.I basecan be any integer in the range 2 to 36, inclusive;or 0 in which case the base can be specified as partof the string, in Limbo style (e.g. 16rffff)..PP.B Tobighas the same specification as.B tointexcept that converts to 64-bit.BR big ..PP.B Tolowerconverts all upper case letters in the string.I sto lower case letters..PP.B Toupperconverts all lower case letters in the string.I sto upper case letters..PP.B Quotedtakes a list of strings,.IR args ,and returns a single string with the value of each element of.I argsseparated from the next by a single space.When forming the string, the text of any element thatcontains white space or single quotes is first quoted bysurrounding it by single quotes.RB ( ' ... ' )within which each existing single quote is doubled.RB ( '' ),following the conventions of.IR sh (1)..PP.B Unquotedtakes a string.IR s ,quoted according to the conventions of.BR quoted ,and splits it into separate strings.It splits the string at each maximal sequence ofunquoted white space (blank, newline or tab),stripping single quotes except where paired,to form the corresponding list of strings,which it returns..SH SOURCE.B /appl/lib/string.b