javascript - match string against the array of regular expressions

前端 未结 8 1543
予麋鹿
予麋鹿 2020-12-02 22:23

Is there a way in JavaScript to get Boolean value for a match of the string against the array of regular expressions?

The example would be (where the \'if\' statemen

8条回答
  •  旧巷少年郎
    2020-12-02 22:45

    look this way...

    function matchInArray(stringSearch, arrayExpressions){
        var position = String(arrayExpressions).search(stringSearch);
        var result = (position > -1) ? true : false
        return result;
    }
    

提交回复
热议问题