Alternatives ()

p1|p2|

is a pattern object that represents any of the patterns pi.

Details

  • If a named pattern such as x_ appears in pi that are not used in a particular match, then the named pattern is taken to have a value that is a zero-length sequence Sequence[].

Examples

open allclose all

Basic Examples  (2)

Replace instances of either a or b:

In[1]:=
Click for copyable input
Out[1]=

Specify a function for several argument types:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Scope  (2)

See Also

Optional  Except  Cases  StringExpression

Tutorials

Introduced in 1991
(2.0)