Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

string - how to check for word phrases as well as words in lists in flutter

I am using below code to filter the text elements from the List A and List D and in which I am successful. Upon printing I am able to get word by word result.

  List A = ["ra", "rb", "rc","ball of ", "rd", "re"];
  List D = ["p", "of","of iron" ,"r", "ball of ", "s", "a"];
    
      String text = "This is a ball of iron";
    
    
bool filterLists2(text) { return [ A ].any((list) => list.contains(text)); }
List newString = text.toLowerCase().split(' ').where(filterLists2).toList();

    bool filterLists1(text) { return [ D ].any((list) => list.contains(text)); }
    List ns = text.toLowerCase().split(' ').where(filterLists1).toList();

But as the word by word separation is done and so the result is also available at the same time I also want to check for the phrases of words if there are any in the text and so in the lists which are being filtered.

How can I do that ? Please guide me

question from:https://stackoverflow.com/questions/65898096/how-to-check-for-word-phrases-as-well-as-words-in-lists-in-flutter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...