({{, s:obj
represents the pattern object obj, assigned the name s. }})

OpenersNotesSection(Spacer1)Details

The name s must be a symbol.

The object obj can be any pattern object.

When a transformation rule is used, any occurrence of s on the right-hand side is replaced by whatever expression it matched on the left-hand side.

The operator : has a comparatively low precedence. The expression x:_+_ is thus interpreted as x:(_+_), not (x:_)+_.

The form s_ is equivalent to s:_. Similarly, s_h is equivalent to s:_h, s__ to s:__, and so on.

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Give a name to lists of integers:

Cases[{{1,2,3},a,{4,5}},t:{__Integer}:>t^2]

Cases[{{1,2,3},a,{4,5}},Pattern[t,{__Integer}]:>t^2]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Blank, paclet:ref/Blank])  ▪  (RefLink[Optional, paclet:ref/Optional])  ▪  (RefLink[PatternTest, paclet:ref/PatternTest])  ▪  (RefLink[StringExpression, paclet:ref/StringExpression])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Introduction to Patterns, paclet:tutorial/Introduction-Patterns])}, {▪(RefLinkPlain[Patterns and Transformation Rules, paclet:tutorial/PatternsAndTransformationRules])}, {▪(RefLinkPlain[Naming Pieces of Patterns, paclet:tutorial/NamingPiecesOfPatterns])}, {▪(RefLinkPlain[Specifying Types of Expression in Patterns, paclet:tutorial/SpecifyingTypesOfExpressionInPatterns])}, {▪(RefLinkPlain[Optional and Default Arguments, paclet:tutorial/OptionalAndDefaultArguments])}, {▪(RefLinkPlain[Pattern Sequences, paclet:tutorial/PatternSequences])}, {▪(RefLinkPlain[Patterns for Some Common Types of Expression, paclet:tutorial/PatternsForSomeCommonTypesOfExpression])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Patterns, paclet:guide/Patterns])}, {▪(RefLinkPlain[Wolfram Language Syntax, paclet:guide/Syntax])}, {▪(RefLinkPlain[String Patterns, paclet:guide/StringPatterns])}, {▪(RefLinkPlain[Programmable Linguistic Interface, paclet:guide/ProgrammableLinguisticInterface])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-FastIntro.png(Spacer1)Fast Introduction for Programmers: Patterns, http://www.wolfram.com/language/fast-introduction-for-programmers/patterns/])}})}})