1×1 cell array
{'jason_blake@mymail.com'}
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-55
• “Character Representation” on page 2-56
• “Quantifiers” on page 2-56
• “Grouping Operators” on page 2-57
• “Anchors” on page 2-58
• “Lookaround Assertions” on page 2-58
• “Logical and Conditional Operators” on page 2-59
• “Token Operators” on page 2-60
• “Dynamic Expressions” on page 2-60
• “Comments” on page 2-61
• “Search Flags” on page 2-61
Metacharacters
Metacharacters represent letters, letter ranges, digits, and space characters. Use them to construct a
generalized pattern of characters.
Metacharacter
Description
Example
.
Any single character, including white
space
'..ain' matches sequences of five
consecutive characters that end with 'ain'.
[c 1 c 2 c 3 ]
Any character contained within the
square brackets. The following
characters are treated literally: $ | . *
+ ? and - when not used to indicate a
range.
'[rp.]ain' matches 'rain' or 'pain' or
'.ain'.
[^c 1 c 2 c 3 ]
Any character not contained within the
square brackets. The following
characters are treated literally: $ | . *
+ ? and - when not used to indicate a
range.
'[^*rp]ain' matches all four-letter
sequences that end in 'ain', except 'rain'
and 'pain' and '*ain'. For example, it
matches 'gain', 'lain', or 'vain'.
[c 1 -c 2 ]
Any character in the range of c 1 through
c 2
'[A-G]' matches a single character in the
range of A through G.
Regular Expressions
2-55
{'jason_blake@mymail.com'}
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-55
• “Character Representation” on page 2-56
• “Quantifiers” on page 2-56
• “Grouping Operators” on page 2-57
• “Anchors” on page 2-58
• “Lookaround Assertions” on page 2-58
• “Logical and Conditional Operators” on page 2-59
• “Token Operators” on page 2-60
• “Dynamic Expressions” on page 2-60
• “Comments” on page 2-61
• “Search Flags” on page 2-61
Metacharacters
Metacharacters represent letters, letter ranges, digits, and space characters. Use them to construct a
generalized pattern of characters.
Metacharacter
Description
Example
.
Any single character, including white
space
'..ain' matches sequences of five
consecutive characters that end with 'ain'.
[c 1 c 2 c 3 ]
Any character contained within the
square brackets. The following
characters are treated literally: $ | . *
+ ? and - when not used to indicate a
range.
'[rp.]ain' matches 'rain' or 'pain' or
'.ain'.
[^c 1 c 2 c 3 ]
Any character not contained within the
square brackets. The following
characters are treated literally: $ | . *
+ ? and - when not used to indicate a
range.
'[^*rp]ain' matches all four-letter
sequences that end in 'ain', except 'rain'
and 'pain' and '*ain'. For example, it
matches 'gain', 'lain', or 'vain'.
[c 1 -c 2 ]
Any character in the range of c 1 through
c 2
'[A-G]' matches a single character in the
range of A through G.
Regular Expressions
2-55
