WLJS LogoWLJS Notebook

StringStartsQ

StringStartsQ["string", patt] yields True if the beginning of the string matches the pattern.

StringStartsQ[patt] represents an operator form.

Examples

Check prefix:

StringStartsQ["Hello World", "Hello"]
(* True *)
StringStartsQ["Hello World", "World"]
(* False *)

Filter strings by prefix:

Select[{"apple", "apricot", "banana"}, StringStartsQ["ap"]]
(* {"apple", "apricot"} *)

Please visit the official Wolfram Language Reference for more details.

On this page