Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

Patterns

Guides

  • Guide
  • MainGuide

Tech Notes

  • Match & Replace

Symbols

  • MatchBindings
  • MatchParts
  • MultiwayReplace
  • NameValuePattern
  • PatternMatch
Match & Replace
PatternMatchQ
MatchQ
with matches
MatchReplace
Replace
with matches
MatchReplaceAll
ReplaceAll
with matches
MatchReplaceList
ReplaceList
with matches
XXXX.

Current behaviour differences:

In[3320]:=
Replace[1,Except[f[x_]]x]
Out[3320]=
Removed[$Variable][1]
In[1666]:=
MatchReplace
[1,Except[f[x_:1]]x]
Out[1666]=
1
In[3322]:=
MatchQ[{},{_.}]
Out[3322]=
False
In[409]:=
PatternMatchQ
[{},{_.}]
Out[409]=
True
In[3324]:=
f[a]+g[a]+h[a]/.(f[x_]+g[x_])x
Out[3324]=
a+h[a]
In[1667]:=
MatchReplaceAll
[Unevaluated[(f[a]+g[a])+h[a]],(f[x_]+g[x_])x]
Out[1667]=
a+h[a]
In[419]:=
f[a]+g[a]+h[a]/.(f[x_]+g[x_])|(g[x_]+h[x_])x
Out[419]=
f[a]+g[a]+h[a]
In[1668]:=
MatchReplaceAll
[Unevaluated[(f[a]+g[a])+h[a]],(f[x_]+g[x_])|(g[x_]+h[x_])x]
Out[1668]=
a+h[a]
In[435]:=
ClearAll[f]
In[1670]:=
SetAttributes[f,{Flat}]
In[437]:=
Replace[f[a,b],x:f[y_]Hold[x,y]]
Out[437]=
Hold[f[a,b],f[a,b]]
In[1671]:=
MatchReplace
[f[a,b],x:f[y_]Hold[x,y]]
Out[1671]=
Hold[f[f[a,b]],f[a,b]]
In[426]:=
ReplaceList[a+b+c,x_+y_HoldComplete[x,y]]
Out[426]=
{HoldComplete[a,b+c],HoldComplete[b,a+c],HoldComplete[c,a+b],HoldComplete[a+b,c],HoldComplete[a+c,b],HoldComplete[b+c,a]}
In[1672]:=
MatchReplaceList
[a+b+c,x_+y_HoldComplete[x,y]]//Normal
Out[1672]=
{HoldComplete[Plus[],a+b+c],HoldComplete[a,b+c],HoldComplete[a+b,c],HoldComplete[a+b+c,Plus[]],HoldComplete[Plus[],a+c+b],HoldComplete[a,c+b],HoldComplete[a+c,b],HoldComplete[a+c+b,Plus[]],HoldComplete[Plus[],b+a+c],HoldComplete[b,a+c],HoldComplete[b+a,c],HoldComplete[b+a+c,Plus[]],HoldComplete[Plus[],b+c+a],HoldComplete[b,c+a],HoldComplete[b+c,a],HoldComplete[b+c+a,Plus[]],HoldComplete[Plus[],c+a+b],HoldComplete[c,a+b],HoldComplete[c+a,b],HoldComplete[c+a+b,Plus[]],HoldComplete[Plus[],c+b+a],HoldComplete[c,b+a],HoldComplete[c+b,a],HoldComplete[c+b+a,Plus[]]}
In[444]:=
MatchQ[HoldComplete[1,2,3,Sequence[1,2,3]],HoldComplete[x___,x_]]
Out[444]=
False
In[1673]:=
PatternMatchQ
[HoldComplete[1,2,3,Sequence[1,2,3]],HoldComplete[x___,x_]]
Out[1673]=
True
​
​
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com