[javascript] 문자열에 특정 문자 개수 확인하기

("검색대상문자".match(new RegExp("확인할문자", "g")) || []).length

// example
("str1,str2,str3,str4".match(new RegExp("str", "g")) || []).length
// Result : 4

Leave a Comment