Google

Yorick Reference Card

yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference

Yorick Function Reference

Manipulating Strings

Yorick type string is a pointer to a 0-terminated array of char. A string with zero characters - "" - differs from a zero pointer - string(0). A string variable s can be converted to a pointer to a 1-D array of char, and such a pointerp can be converted back to a string: p=pointer(s); s=string(p); These conversions copy the characters, so you can't use the pointer p to alter the characters of s.

Given a string or an array of strings s:

strlen(s )           number of characters in each element of s
strmatch(s, pat)     1 if pat occurs in
strmatch(s, pat, 1)  1 if pat occurs in s, case insensitive
strpart(s, m:n)      returns substring of s
strtok(s, delims)    gets first token of s
strtok(s)            gets first whitespace delimited token of s

The strtok function returns a 2-by-dimsof(s) array of strings - the first token followed by the remainder of the string. The token will be string(0) if no tokens were present; the remainder of string will be string(0) if there are no characters after the token.