next up previous contents
Next: Searching with SGML Tags Up: Exact string Search Previous: String Format Scan -

Searching for Strings

SearchString(pattern, target : name)
CaseSearchString(pattern , target : name)

Darwin offers two high level functions - CaseSearchString and SearchString - to find a pattern in an item of type string. The first is case sensitive (meaning the strings hello and Hello are not equivalent); the second is not. Both commands take two string parameters; the first parameter is the pattern and the second is the target. If the pattern is found in target, the position before the character where pattern was found in target is returned. If the pattern is not found, the value -1 is returned.

> SearchString('WaldO', 'canyoufindwaldoinhere');      # case insensitive
> CaseSearchString('it', 'It is in here');             # case sensitive
> SearchString('am', 'Here I am');                     # not found

Gaston Gonnet