regexp

Returns the results after searching for the regular expression or pattern, pattern in the input.s.

Syntax

[startidx, endidx, extent, match, token, namedtoken, unmatchedtoken] = regexp(s, pattern)

Inputs

s
Type: string | mat
pattern
Pattern to match.
Type: string

Outputs

startidx
Start index of each substrings matching the pattern.
Type: integer
endidx
End index of each substrings matching the pattern.
Type: integer
extent
The extents or ranges of matched tokens.
Type: cell
match
Cell array of matched substrings.
token
Cell array of matched tokens.
Type: cell
namedtoken
Cell array of matched, named tokens.
Type: cell
unmatchedtoken
Cell array of unmatched tokens.
Type: cell

Example

[startidx, endidx, extent, match, token, namedtoken, unmatchedtoken] = regexp('test',['test';'test'])
startidx = 1
endidx = 4
extent =
{
[1,1] [Matrix] 0 x 2
}
match =
{
[1,1] test
}
token =
{
[1,1]
{
}

}
namedtoken = struct [

]
unmatchedtoken =
{
[1,1]
[1,2]
}
e = 4
te =
{
[1,1] [ ]
}

m =
{
[1,1] test
}

t =
{
[1,1]
{
}

}

nm = struct [

]
sp =
{
[1,1]
[1,2]
}