1×1 cell array
{'p'}
ans =
1×1 cell array
{'d'}
ans =
1×1 cell array
{'p'}
The cell array ext contains numeric arrays that each contain starting and ending indices for a token.
ext{:}
ans =
11
11
ans =
26
26
ans =
35
35
ans =
57
57
For another example, capture pairs of matching HTML tags (e.g., and ) and the text
between them. The expression used for this example is
expr = '<(\w+).*?>.*?';
The first part of the expression, '<(\w+)', matches an opening angle bracket (<) followed by one or
more alphabetic, numeric, or underscore characters. The enclosing parentheses capture token
characters following the opening angle bracket.
The second part of the expression, '.*?>.*?', matches the remainder of this HTML tag (characters
up to the >), and any characters that may precede the next opening angle bracket.
The last part, '', matches all characters in the ending HTML tag. This tag is composed of the
sequence , where tag is whatever characters were captured as a token.
hstr = 'Default
';
expr = '<(\w+).*?>.*?';
Tokens in Regular Expressions
2-67
Précédent

- 117/1450

Suivant