How do I perform case insensitive string comparison in JavaScript?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- how to split a list into a given number of sub-lis
This is an improved version of this answer.
Usages & tests:
Even this question have already answered. I have a different approach to use RegExp and match to ignore case sensitive. Please see my link https://jsfiddle.net/marchdave/7v8bd7dq/27/
The simplest way to do it (if you're not worried about special Unicode characters) is to call
toUpperCase
:I have recently created a micro library that provides case-insensitive string helpers: https://github.com/nickuraltsev/ignore-case. (It uses
toUpperCase
internally.)I wrote a extension. very trivial