Scanning strings in Icon and Unicon
Unicon inherits this domain control structure from its immediate predecessor, Icon. String scanning is invoked by the s ? expr
syntax. Within expr
, s
is the scanning subject and referenced by a global keyword called &subject
. Within the subject string, a current analysis position, which is stored in the &pos
keyword, denotes the index location in the subject string where it is being examined. The position starts at the beginning of the string and can be moved back and forth, typically working its way toward the end of the string. For example, in the following program, s
contains "For example, suppose string s contains"
:
procedure main() s := "For example, suppose string s contains" s ? { tab(find("suppose")) write("after tab()") } end
Now, let's say we were to add...