REGEXP Regular Expression Matching Function

Section: String Functions

Usage

Matches regular expressions in the provided string. This function is complicated, and compatibility with MATLABs syntax is not perfect. The syntax for its use is
  regexp('str','expr')

which returns a row vector containing the starting index of each substring of str that matches the regular expression described by expr. The second form of regexp returns six outputs in the following order:

  [start stop tokenExtents match tokens names] = regexp('str','expr')

where the meaning of each of the outputs is defined below.

If you want only some of the the outputs, you can use the following variant of regexp:
  [o1 o2 ...] = regexp('str','expr', 'p1', 'p2', ...)

where p1 etc. are the names of the outputs (and the order we want the outputs in). As a final variant, you can supply some mode flags to regexp

  [o1 o2 ...] = regexp('str','expr', p1, p2, ..., 'mode1', 'mode2')

where acceptable mode flags are:

Note the following behavior differences between MATLABs regexp and FreeMats:

Example

Some examples of using the regexp function
--> [start,stop,tokenExtents,match,tokens,named] = regexp('quick down town zoo','(.)own')
start = 
  7 12 

stop = 
 10 15 

tokenExtents = 
 [1 2 double array] [1 2 double array] 

match = 
 [down] [town] 

tokens = 
 [1 1 cell array] [1 1 cell array] 

named = 
  []