-
Notifications
You must be signed in to change notification settings - Fork 14
/
regexpisymbols.m
66 lines (65 loc) · 2.67 KB
/
regexpisymbols.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%REGEXPI Match regular expressions, ignoring case.
% START = REGEXPI(STRING,EXPRESSION) returns a row vector, START, which
% contains the indices of the substrings in STRING that match the regular
% expression string, EXPRESSION, regardless of case.
%
% In EXPRESSION the following symbols have special meaning:
%
% Symbol Meaning
% -------- --------------------------------
% ^ start of string
% $ end of string
% . any character
% \ quote next character
% * match zero or more
% + match one or more
% ? match zero or one, or match minimally
% {} match a range of occurrances
% [] set of characters
% [^] exclude a set of characters
% () group subexpression
% \w match word [a-z_A-Z0-9]
% \W not a word [^a-z_A-Z0-9]
% \d match digit [0-9]
% \D not a digit [^0-9]
% \s match white space [ \t\r\n\f]
% \S not a white space [^ \t\r\n\f]
% <WORD\> exact word match
%
% Example
% str = 'My flowers may bloom in May';
% pat = 'm\w*y';
% regexpi(str, pat)
% returns [1 12 25]
%
% which is a row vector of indices that match words that start with m, and
% end with y regardless of case.
%
% When either STRING or EXPRESSION is a cell array of strings, REGEXPI returns
% an MxN cell array of row vectors of indices, where M is the the number of
% strings in STRING and N is the number of regular expression patterns in
% EXPRESSION.
%
% [START,FINISH] = REGEXPI(STRING,EXPRESSION) returns an additional row
% vector, FINISH, which contains the indices of the last character of the
% corresponding substrings in START.
%
% [START,FINISH,TOKENS] = REGEXPI(STRING,EXPRESSION) returns a 1xN cell array,
% TOKENS, of beginning and ending indices of tokens within the corresponding
% substrings in START and FINISH. Tokens are denoted by parenthesis in
% EXPRESSION.
%
% By default, REGEXPI returns all matches. To find just the first match, use
% REGEXPI(STRING,EXPRESSION,'once'). If no matches are found then START,
% FINISH, and TOKENS are empty.
%
% REGEXPI does not support international character sets.
%
% See also REGEXP, REGEXPREP, STRCMPI, STRFIND, FINDSTR, STRMATCH.
%
%
% E. Mehran Mestchian
% J. Breslau
% Copyright 1984-2002 The MathWorks, Inc.
% $Revision: 1.5 $ $Date: 2002/04/09 00:33:35 $
%