Js code that determines whether a character exists in a string

  • 2020-03-30 02:11:53
  • OfStack

 
$(function(){ 
var str="sunny,woo"; 
var sear=new RegExp(','); 
if(sear.test(str)) 
{ 
alert('Yes'); 
} 
var tag=','; 
if(str.indexOf(tag)!=-1) 
{ 
alert('Yes'); 
} 
}); 

Related articles: