MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
regexp(contacts{5}, email, 'match')

ans =

1×1 cell array

{'[email protected]'}

You can also search for the email address of everyone in the list by using the entire cell
array for the input argument:

regexp(contacts, email, 'match');

Operators and Characters


Regular expressions can contain characters, metacharacters, operators, tokens, and flags
that specify patterns to match, as described in these sections:


  • “Metacharacters” on page 2-46

  • “Character Representation” on page 2-48

  • “Quantifiers” on page 2-48

  • “Grouping Operators” on page 2-49

  • “Anchors” on page 2-50

  • “Lookaround Assertions” on page 2-51

  • “Logical and Conditional Operators” on page 2-52

  • “Token Operators” on page 2-52

  • “Dynamic Expressions” on page 2-54

  • “Comments” on page 2-55

  • “Search Flags” on page 2-55


Metacharacters

Metacharacters represent letters, letter ranges, digits, and space characters. Use them to
construct a generalized pattern of characters.

2 Program Components

Free download pdf