Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
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.

share|improve this question
6  
Use Shortest[__] –  rm -rf May 14 at 21:40
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.