Regex to check whether string starts with, ignoring case differences

后端 未结 5 2050
野性不改
野性不改 2020-12-29 03:23

I need to check whether a word starts with a particular substring ignoring the case differences. I have been doing this check using the following regex search pattern but th

5条回答
  •  天涯浪人
    2020-12-29 03:38

    In this page you can see that modifiers can be added as second parameter. In your case you're are looking for 'i' (Canse insensitive)

    //Syntax
    var patt=new RegExp(pattern,modifiers);
    
    //or more simply:
    
    var patt=/pattern/modifiers;
    

提交回复
热议问题