I am trying to write a REGEX to test for a PANGRAM. I can do it the traditional way, but cannot seem to solve it for more than 90% of my tests with a regular expression.
Input: string
Output: true || false
function isPangram(string){
return ___________________.test(string)
}
Test Results so far.
6/10
/([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z, \s]+)/i
6/10
/[a-z]{1}/i
6/10 /[a-z]/i
6/10 /[a-z]+/i
9/10 /a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z/i
only failed against abcdefghijklmopqrstuvwxyz
6/10 /[\w.]+/
Any help or advice is greatly appreciated.
Code:
function isPangram(string) {
var regex = /([a-z])(?!.*\1)/g;
return (string.match(regex) || []).length === 26;
}
var regex = /([a-z])(?!.*\1)/g;
function check() {
var val = document.getElementById('text').value.toLowerCase();
alert(val.match(regex).length == 26);
}
<input type="text" id="text" />
<button onclick="check()">Check</button>