This code works fine in a string based interface like WolframScript or Mathematica Kernel.
Run this through a string based interface
StringCases["hello", x_..]
Or do
ToExpression["StringCases[\"hello\", x_..]"]
in the notebook. Both work correctly, x_..
is interpreted as a Repeated
form of the pattern x_
,
In the notebook based front end, however, it fails because x_.
is interpreted as a Default
pattern and the second dot throws a syntax error.
The code must be modified to
StringCases["hello", (x_)..]
(* {"h", "e", "ll", "o"} *)
Why is there a difference in behavior between the front end and kernel parsers.