Regex to check whether string starts with, ignoring case differences

后端 未结 5 2048
野性不改
野性不改 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 04:04

    Pass the i modifier as second argument:

    new RegExp('^' + query, 'i');
    

    Have a look at the documentation for more information.

提交回复
热议问题