我需要檢查一個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