use lodash to find substring from array of strings

前端 未结 7 2523
清歌不尽
清歌不尽 2021-02-14 05:03

I\'m learning lodash. Is it possible to use lodash to find a substring in an array of strings?

    var myArray = [
    \'I like oranges and apples\',
    \'I hat         


        
7条回答
  •  醉酒成梦
    2021-02-14 05:07

    let str1 = 'la rivière et le lapin sont dans le près';
    let str2 = 'product of cooking class';
    let str3 = 'another sentence to /^[analyse]/i with weird!$" chars@';
    
    _.some(_.map(['rabbit','champs'], w => str1.includes(w)), Boolean), // false
    _.some(_.map(['cook'],            w => str2.includes(w)), Boolean), // true
    _.some(_.map(['analyse'],         w => str3.includes(w)), Boolean), // true
    

提交回复
热议问题