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)
[startidx, ...] = regexp(s, pattern, options)
Inputs
- s
- Type: string | mat
- pattern
- The pattern to match.
- options (optional)
- Argument(s) specifying the search pattern. Currently supported options include:
- ignorecase
- Ignores the case when matching the pattern.
- matchcase
- Matches the case when matching the pattern.
Outputs
- startidx
- Start index of each substring matching the pattern.
- endidx
- End index of each substring matching the pattern.
- extent
- The extents or ranges of matched tokens.
- match
- Cell array of matched substrings.
- token
- Cell array of matched tokens.
- namedtoken
- Cell array of matched, named tokens.
- unmatchedtoken
- Cell array of unmatched tokens.
Examples:
[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]
}
R = regexp({'FILE021.prn', 'FILE0.prn'}, '.PRN','ignorecase')
R =
{
[1,1] 8
[1,2] 6
}
R = regexp({'FILE021.prn', 'FILE0.PRN'}, '.PRN','matchcase')
R =
{
[1,1] [Matrix] 1 x 0
[1,2] 6
}