WolframLang: String Expression

By Xah Lee. Date: . Last updated: .

What is String Expression

String Expression represents a string pattern. It is WolframLang's alternative syntax comparable to Regular Expression.

String Expression has a syntax that is more readable, and similar to WolframLang: Pattern Syntax for matching symbolic expression structures.

StringExpression[s1, s2, etc]

🔸 SHORT SYNTAX: s1 ~~ s2 ~~ etc

Represents a string pattern, used in string functions that take a string pattern.


WolframLang StringExpression 2022-04-29
WolframLang StringExpression 2022-04-29

StringExpression Short Syntax

StringExpression[ a, b, c, etc ]

is equivalent to

(a ~~ b ~~ c ~~ etc)

StringExpression Pattern Syntax

Example: StringExpression

(* catch email address *)

 "joe@mcqxf.com and mary@nvsck.org",
 LetterCharacter.. ~~ "@" ~~ LetterCharacter.. ~~ "." ~~ LetterCharacter..
(* {joe@mcqxf.com, mary@nvsck.org} *)

Ignore Case

To ignore case, use the option IgnoreCase -> True

(* match string, ignore case *)
StringCases["Some Thing", StringExpression["thing"], IgnoreCase -> True]

(* {"Thing"} *)

WolframLang String