我需要检查一个string A
根据它是否包含另一个string B
中的所有单词 - 以任何顺序进行匹配。如何搜索第二个字符串中包含的所有单词的一个字符串?
所以,让我们说string A
是这样的:
one two three four five
而且string B
就是其中之一:
one two three // match!
one three two // match! (order doesn't matter)
one two six // NOT A MATCH! ('six' is not found in string A)
one two three four // match!
one two three four five // match!
one two three four five seven // NOT A MATCH! ('seven' is not found in string A)
我怎么会觉得string A
和string B
之间的匹配只有有的话在string B
ý字在string A
(不管任一字符串中的单词的顺序的且不论string A
是否包含附加字未在string B
找到)被发现?
我不知道jQuery是否有任何特殊功能可以帮助解决这个问题,或者我是否需要严格使用纯JavaScript来做到这一点?
你有字符串A和字符串B,取每个字从字符串B中检查它是否存在于字符串A中,如果不存在则返回false,它应该非常简单。 – kobe 2010-11-22 01:53:59