This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
 Built-in Mathematica Symbol Tutorials »| See Also »| More About »

# StringPosition

 StringPosition["string", "sub"]gives a list of the starting and ending character positions at which "sub" appears as a substring of "string". StringPosition["string", patt]gives all positions at which substrings matching the general string expression patt appear in "string". StringPosition["string", patt, n]includes only the first n occurrences of patt. StringPosition["string", {patt1, patt2, ...}]gives positions of all the patti. StringPosition[{s1, s2, ...}, p]gives the list of results for each of the si.
• The string expression patt can contain any of the objects specified in the notes for StringExpression.
• With the default option setting , StringPosition includes substrings that overlap. With the setting such substrings are excluded.  »
• With , multiple substrings that match the same string expression are all included. With , only the first such matching substring at a given position is included.  »
• Setting the option makes StringPosition treat lowercase and uppercase letters as equivalent.  »
Find the starting and ending positions at which XYZ occurs in a string:
 Out[1]=

Find where any pairs of identical characters occur:
 Out[1]=
 Scope   (4)
 Options   (4)
 Applications   (2)
New in 2 | Last modified in 5.1