BUILT-IN MATHEMATICA SYMBOL

# StringExpression

or StringExpression[s1, s2, ...]
represents a sequence of strings and symbolic string objects .

## DetailsDetails

• yields an ordinary string obtained by concatenating the characters in the .
• The following objects can appear in StringExpression:
•  "string" a literal string of characters _ any single character __ any substring of one or more characters ___ any substring of zero or more characters , , x___ substrings given the name x x:pattern pattern given the name x pattern.. pattern repeated one or more times pattern... pattern repeated zero or more times or a pattern matching at least one of the patt/;cond a pattern for which cond evaluates to True pattern?test a pattern for which test yields True for each character Whitespace a sequence of whitespace characters NumberString the characters of a number DatePattern[spec] the characters of a date charobj an object representing a character class (see below) RegularExpression["regexp"] substring matching a regular expression StringExpression[...] an arbitrary string expression
• The following represent classes of characters:
•  {c1,c2,...} any of the Characters["c1c2..."] any of the CharacterRange["c1","c2"] any character in the range to HexadecimalCharacter hexadecimal digit 0-9, a-f, A-F DigitCharacter digit 0-9 LetterCharacter letter WhitespaceCharacter space, newline, tab, or other whitespace character WordCharacter letter or digit Except[p] any character except ones matching p
• The following represent positions in strings:
•  StartOfString start of the whole string EndOfString end of the whole string StartOfLine start of a line EndOfLine end of a line WordBoundary boundary between word characters and others Except[WordBoundary] anywhere except a word boundary
• When constructs like or are present, there may be several different ways in which a given StringExpression can match a particular string.
• By default, Mathematica will use the one that makes pattern elements that appear earlier in the StringExpression match the longest possible substrings.
• The following determine which match will be used if there are several possibilities:
•  Shortest[p] the shortest consistent match for p Longest[p] the longest consistent match for p (default)
• In matching ordinary expressions instead of strings, the shortest instead of the longest consistent match is used.
• StringExpression objects can be used in many string manipulation functions, including StringReplace, StringCases, StringSplit, and StringMatchQ.
• StringExpression has attributes Flat and OneIdentity.

## ExamplesExamplesopen allclose all

### Basic Examples (2)Basic Examples (2)

A string expression representing the string followed by any single character:

 Out[1]=

This makes a replacement for each occurrence of the string pattern :

 Out[2]=

Give all pairs of identical characters in the string:

 Out[1]=