Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js string contains substring ignore case

const str = 'arya stark';

// The most concise way to check substrings ignoring case is using
// `String#match()` and a case-insensitive regular expression (the 'i')
str.match(/Stark/i); // true
str.match(/Snow/i); // false

// You can also convert both the string and the search string to lower case.
str.toLowerCase().includes('Stark'.toLowerCase()); // true
str.toLowerCase().indexOf('Stark'.toLowerCase()) !== -1; // true

str.toLowerCase().includes('Snow'.toLowerCase()); // false
str.toLowerCase().indexOf('Snow'.toLowerCase()) !== -1; // false
Comment

PREVIOUS NEXT
Code Example
Javascript :: wait one second in javascript using async wait 
Javascript :: angular add object to array 
Javascript :: finding in mongoose using a name 
Javascript :: javascript load multiple images 
Javascript :: number to array javascript 
Javascript :: get nearby store by latitude and longitude from my latitude and long node js 
Javascript :: get previous route 
Javascript :: javascript on enter 
Javascript :: find element in array javascript 
Javascript :: Exceeded timeout of 5000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 
Javascript :: javascript print object pretty 
Javascript :: how to get clicked element class in jquery 
Javascript :: jquery get textarea text 
Javascript :: how to swap two variables in js 
Javascript :: javascript un hiden element 
Javascript :: drupal 8 get node from form 
Javascript :: how to find the last item in a javascript object 
Javascript :: eslint ignore file rule 
Javascript :: submit form automatically javascript 
Javascript :: iffi in js 
Javascript :: js object for each 
Javascript :: how to return 5 records instead of 10 records in datatable 
Javascript :: adding event listener keypress event in javascript 
Javascript :: math.rount 
Javascript :: jquery on dom change 
Javascript :: js check if two array have the same element 
Javascript :: how do i remove all vowels from a string in javascript and return the result 
Javascript :: random number in range js 
Javascript :: array remove empty entrys js 
Javascript :: convert a string to an integer in javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =