MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
tok{:}

ans =

1×1 cell array

{'a'}

ans =

1×1 cell array

{'b'}

Multiple Tokens


Here is an example of how tokens are assigned values. Suppose that you are going to
search the following text:

andy ted bob jim andrew andy ted mark

You choose to search the above text with the following search pattern:

and(y|rew)|(t)e(d)

This pattern has three parenthetical expressions that generate tokens. When you finally
perform the search, the following tokens are generated for each match.

Match Token 1 Token 2
andy y
ted t d
andrew rew
andy y
ted t d

Only the highest level parentheses are used. For example, if the search pattern and(y|
rew) finds the text andrew, token 1 is assigned the value rew. However, if the search
pattern (and(y|rew)) is used, token 1 is assigned the value andrew.

2 Program Components

Free download pdf