Home > Web Front-end > JS Tutorial > Javascript's indexOf method to ignore case_javascript tips

Javascript's indexOf method to ignore case_javascript tips

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 19:01:50
Original
1864 people have browsed it

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


[Ctrl A Select All Note: If you need to introduce external Js, you need to refresh to execute
]

[Ctrl A Select All Note:
If you need to introduce external Js, you need to refresh to execute
]

Take a look at this, it’s compatible with the original indexOf
[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>]
Related labels:
Statement of this Website
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template