我试图有效地检查一个字符串是否与任何一个正则表达式匹配,并在第一个遇到的匹配中返回true(在正则表达式上打破迭代)
我目前的代码:
- _.forEach(self._connectedClients,function(client) {
- if (client.authenticated) {
- var interested = _.forEach(client.interests,function(interest) {
- if (evt.event_type.search(interest) != -1) {
- return true;
- }
- });
- if (interested) {
- self._sendJSON(client.socket,data);
- }
- }
- });
兴趣是一系列正则表达式.
有什么建议?
提前致谢