If I have a list of strings Like:
text = Select[
StringSplit[
StringReplace[
StringTake[ExampleData[{"Text", "AliceInWonderland"}], {25, 997}],
Alternatives @@ Characters["<>?;'|:\"()-_!&"] -> " "], "." | ","],
StringLength[#] > 2 &]
{"Alice was beginning to get very tired of sitting by her sister on the bank"," and of having nothing to do"," Once or twice she had peeped into the book her sister was reading"," but it had no pictures or conversations in it"," and what is the use of a book"," thought Alice"," without pictures or conversations So she was considering in her own mind as well as she could"," for the day made her feel very sleepy and stupid "," whether the pleasure of making a daisy chain would be worth the trouble of getting up and picking the daisies"," when suddenly a White Rabbit with pink eyes ran close by her"," There was nothing so very remarkable in that"," nor did Alice think it so very much out of the way to hear the Rabbit say to itself"," Oh dear Oh dear I shall be too late But when the Rabbit actually took a watch out of its waistcoat pocket and looked at it and then hurried on"," Alice started to her feet"," for it flashed across her mind that she had never before seen a rabbit with "}
how do I find the positions of the list elements that contain the following words/character strings:
words = {"her", "she", "alice", "bbit"};
Following on from this question, I tried using Position
like so:
Position[text,
s_ /; StringMatchQ[s, __ ~~ Alternatives @@ words ~~ __,
IgnoreCase -> True] &]
{}
but this doesn't produce the list of positions. The follwing seems to suggest that I have the right string-matching criteria:
StringMatchQ[text, __ ~~ Alternatives @@ words ~~ __,
IgnoreCase -> True]
{True,False,True,False,False,False,True,True,True,True,True,True,True,True,True}
What am I missing?