WLJS LogoWLJS Notebook

StringPosition

StringPosition["string", "sub"] gives a list of {start, end} positions where the substring appears.

StringPosition["string", patt, n] includes only the first n occurrences.

Examples

Find positions:

StringPosition["abcabc", "bc"]
(* {{2, 3}, {5, 6}} *)

First occurrence only:

StringPosition["abcabc", "bc", 1]
(* {{2, 3}} *)

Please visit the official Wolfram Language Reference for more details.

On this page