RegEx Ignore Case

后端 未结 3 1064
慢半拍i
慢半拍i 2020-12-05 22:46

I\'ve been trying to create a regex which would ignore the casing.

This is the regex i am trying to use:

/^[A-Za-z0-9._+\\-\\\']+@+test.com$/;
         


        
3条回答
  •  青春惊慌失措
    2020-12-05 23:29

    For anyone else who arrives here looking for this, if you've got code that is using the RegExp constructor you can also do this by specifying flags as a second argument:

    new RegExp(pattern[, flags])
    

    https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp

    For example:

    var pattern = /^[A-Za-z0-9._+\-\']+@+test.com$/;
    var regExp = new RegExp(pattern, "i");
    

提交回复
热议问题