Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

When I try to figure out this problemthis problem,I write such code:

words = Catenate[ WordList[#, Language -> "English", IncludeInflections -> True] & /@ {"KnownWords", "Stopwords"}]; string = StringReplace[ "What is the best approach to a problem like this in Mathematica?", " " -> ""]; StringCases[string, __?(MemberQ[words, ToLowerCase[#]] &)] 

{"WhatisthebestapproachtoaproblemlikethisinMathematica"}

But I am confused why I get whole string?What's mistake I have made?

When I try to figure out this problem,I write such code:

words = Catenate[ WordList[#, Language -> "English", IncludeInflections -> True] & /@ {"KnownWords", "Stopwords"}]; string = StringReplace[ "What is the best approach to a problem like this in Mathematica?", " " -> ""]; StringCases[string, __?(MemberQ[words, ToLowerCase[#]] &)] 

{"WhatisthebestapproachtoaproblemlikethisinMathematica"}

But I am confused why I get whole string?What's mistake I have made?

When I try to figure out this problem,I write such code:

words = Catenate[ WordList[#, Language -> "English", IncludeInflections -> True] & /@ {"KnownWords", "Stopwords"}]; string = StringReplace[ "What is the best approach to a problem like this in Mathematica?", " " -> ""]; StringCases[string, __?(MemberQ[words, ToLowerCase[#]] &)] 

{"WhatisthebestapproachtoaproblemlikethisinMathematica"}

But I am confused why I get whole string?What's mistake I have made?

Tweeted twitter.com/StackMma/status/751013469080748032
edited tags
Link
Source Link
yode
  • 27.8k
  • 4
  • 69
  • 183

Why the pattern match don't work as expected

When I try to figure out this problem,I write such code:

words = Catenate[ WordList[#, Language -> "English", IncludeInflections -> True] & /@ {"KnownWords", "Stopwords"}]; string = StringReplace[ "What is the best approach to a problem like this in Mathematica?", " " -> ""]; StringCases[string, __?(MemberQ[words, ToLowerCase[#]] &)] 

{"WhatisthebestapproachtoaproblemlikethisinMathematica"}

But I am confused why I get whole string?What's mistake I have made?