programming-examples/js/String/Create a case-insensitive search.js

15 lines
467 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function case_insensitive_search(str, search_str)
{
var result= str.search(new RegExp(search_str, "i"));
if (result>0)
return 'Matched';
else
return 'Not Matched';
}
console.log(case_insensitive_search('JavaScript Exercises', 'exercises'));
console.log(case_insensitive_search('JavaScript Exercises', 'Exercises'));
console.log(case_insensitive_search('JavaScript Exercises', 'Exercisess'));