只获得比赛,而不是整场比赛

时间:2016-02-17 23:43:06

标签: javascript arrays regex

this thread的帮助下,我得到了以下代码,它可以找到至少包含3个字母的所有单词:

arr = ["ab", "abcdef", "ab test"]

var AcceptedItems = arr.filter(function(item) {
    return item.match(/[a-zA-Z]{3,}/);
});

在我的情况下应该是abcdeftest

但不是仅仅出现,它会得到数组的整个条目。因此,test不仅仅是ab test,而是test

如何只获得匹配(Session.Query<IProfile>() .Where(profile => Session.Query<IProfile>() .Where(pf => accountIds.Contains(pf.AccountId)) .GroupBy(pf => pf.AccountId) .Select(kv => kv.Max(pf => pf.Id)) // subQuery .Any(id => profile.Id == id)) // outQuery .Fetch(profile => profile.User) .Fetch(profile => profile.Email); ),而不是整个数组条目。

1 个答案:

答案 0 :(得分:1)

SELECT B AS date,COUNT(C) AS sessions FROM table GROUP BY B,C 将保留一个元素,如果它与您传递的谓词匹配,但您需要根据该谓词是否为真来保存新值。您可以先执行.filter然后map执行此操作,但我宁愿在一个循环中执行此操作。

filter
相关问题