Change them all into uppercase or lowercase, and then compare them
The character position of the first occurrence of the substring in the indexOf object
Use toLowerCase or toUpperCase
]
If you need to introduce external Js, you need to refresh to execute
]
[Ctrl A select all Note: <script>
var testStr = 'ABCDEF';
var subStr = 'bcd';
alert(testStr.toLowerCase().indexOf(subStr.toLowerCase()));
testStr = 'AbCdEf';
alert(testStr.toLowerCase().indexOf(subStr.toLowerCase()));
</script>If you need to introduce external Js, you need to refresh to execute <script>
String.prototype.indexOf = function(f,m){
var mm = (m == false) ? "i":"";
var re = eval("/"+ f +"/"+mm);
var rt = this.match(re);
return (rt == null) ? -1:rt.index;
}
var test = "absnegKIugfkalg";
alert(test.indexOf("kiu",false));
</script>]
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn