String Patterns

The Wolfram Language's symbolic string patterns provide a compact yet readable basis for sophisticated string operations. Included directly in programs, or symbolically generated on the fly, the Wolfram Language's string patterns can routinely be used on strings with millions of elements.

StringExpression a symbolic string-pattern expression (s~~s~~s)

_ any character

__, ___ sequences of characters (one or more, zero or more)

p|p|p alternatives

p.., p... repeated patterns

x_, x:p named patterns

Shortest, Longest shortest, longest matches

Except matches that exclude a pattern

Whitespace  ▪  NumberString  ▪  DatePattern

WordCharacter  ▪  DigitCharacter  ▪  LetterCharacter  ▪  WhitespaceCharacter  ▪  PunctuationCharacter

WordBoundary  ▪  StartOfLine  ▪  EndOfLine  ▪  StartOfString  ▪  EndOfString


RegularExpression string patterns in regular expression notation

IgnoreCase option for whether to ignore case

Overlaps option for how to treat substring overlaps

StringFormat test the overall format of a string

Operations »

StringMatchQ  ▪  StringContainsQ  ▪  StringCases  ▪  StringReplace  ▪  ...