단어 필터 안에 최소한 숫자 나 문자가 있는지 확인하는 조건을 추가 할 수 있습니다.
words = word.filter(function(word) {
return word.length > 0 && word.match(/^[A-Za-z0-9]/);
}).length;
JSFiddle
-------------------다음 코드를 사용할 수 있습니다.
words = word.filter(function(word) {
var pattern = /^[a-zA-Z0-9_']*$/;
if (pattern.test(word)) {
return word.length > 0
}
}).length;
영숫자 만 원한다고 가정합니다.
여기에서 작동하는 데모를 볼 수 있습니다 : http://jsfiddle.net/tKKY6/4/
편집 :/^[a-zA-Z0-9_']*$/
필요에 따라 업데이트 할 수 있습니다 .
출처
https://stackoverflow.com/questions/22008823