# StringCount in Mathematica

StringCount["one letters three letters letters one letters letters three letters",
"one" ~~ __ ~~ "three"]


gives

1


because there is the one occurence of "one [letters three letters letters one letters letters] three [letters]"

It took me some time to understand that Mathematica "thinks" in this way because I expected the value

2


due to "one letters three letters letters one letters letters three letters"

Now I am facing the problem of finding the code that solves this problem in my desired way.

-
Use Shortest[__] – R. M. May 14 '14 at 21:40
– Jacob Akkerboom May 15 '14 at 15:35