News flash: I'm going to Australia in February, so this Web site may be switched off at any time.


Checking for an initial substring in Icon

To check whether a string begins with a particular sequence of characters, use the function

    match ( t, s )
where t is the target string to be searched for, and s is the string to be searched.

For example, the expression

    match ( "foo", "rumplestiltskin" )
fails, while the expression
    match ( "foo", "foobar" )
succeeds and returns the value 4, which is the position just to the left of the "bar" in the second argument.
Next: Scanning for a substring in Icon
See also: Using the Icon programming language
Previous: Checking initial string characters in Icon

John W. Shipman, john@nmt.edu