Compare part of string in JavaScript

后端 未结 7 2021
感动是毒
感动是毒 2020-12-31 01:12

How do I compare a part of a string - for example if I want to compare if string A is part of string B. I would like to find out this: When string A = \"abcd\"

相关标签:
7条回答
  • 2020-12-31 02:06

    Using regular expression might help you.

    var patt = new RegExp(stringA, 'i');
    if(stringB.match(patt)){                            
       return true;
    }
    
    0 讨论(0)
提交回复
热议问题