
Simple pattern matching looks at the contents of one variable, called the subject, and compares it with
another string (or variable) called the pattern. The success or failure of the match can be used to make decisions.
2 The example below
shows the contents of "subjectString" being compared to the contents of patternString and to the string 'this is'.
subjectString = ' this is my string '
patternString = 'string'
subjectString patternString
subjectString 'this is'

A pattern can be matched and replaced within a string. For example, all
the occurences of the pattern 'jack' in "string3" could be replaced with 'jill'.
However, without setting "&anchor = 0" pattern matching only matches the first occurence of a pattern within
a string,in order to match multiple occurences, anchor must be set to 0. If anchor is set to 1 (which is the default) only the first occurence of 'jack' in the
subject would be replaced with 'jill' but not the second however, since anchor is set to 0 both occurences of 'jack' will be matched and replaced with 'jill'.
&anchor = 0

string3 = 'jack be nimble jack be quick'

string3 'jack' = 'jill'

Labels are composed of any characters, but they must begin with a letter, and they MUST start in the
first character position of a line and be seperated by at least one space from the rest of the statement. (Note: END is a special label and must be the last
statement of a SNOBOL program.
2)
thislabel stringVar = 'statement'

There are three different kinds of goto statements. All goto statements are preceded by a colon (":").
Unconditional goto statements follow the colon with ":(labelName)". An unconditional goto will goto the label regardless of the success or failure of the statement
that precedes it. A success goto follows the colon with ":S(labelName)", only if the statement is true does the program goto the label listed. A failure goto follows
the colon with ":F(labelName)", only if the statement was false does the program goto the label.

thisVar = 'goto'

thisVar 'goto' :S(success)
success thisVar 'failure' :F(failure)
failure thisVar 'trueOrFalse' :(unconditional)
unconditional

Beyond simple pattern matching, there are builtin functions that enable the programmer to do more advanced
pattern matching, and string manipulation operations. the "LEN(number)" function will match the first n characters in a string, the cursor is then placed after at the
n + 1 location in the string. Using the "." operator, a substring can be extracted from a string and assigned to another variable.
someString LEN(4)
someString LEN(4) . aVariable

The "BREAK()" function matches all the characters up to, but not including, the character(s) specified in the
function call. More than one character can be specified, such as "BREAK(',.')" matches all characters up to but not including a comma or a dot.
myVar = 'jack be nimble'
myVar BREAK('n')

The "SPAN(string)" function matches an uninterupted sequence of one or more of the characters in "string"
irregardless of order. In the following example, "SPAN('kcaj b')" matches the first 6 characters of myVar "jack b" as they are contained within the span string.
myVar = 'jack be nimble'
myVar SPAN('bkcaj ')