javascriptregexpangram

Javascript Pangram Regex


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.


Solution

  • This would be a correct answer for the challenge:

    function isPangram(string){ 
       return /(?=.*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.test(string) 
    }
    

    It uses lookaheads with every letter to check that they are somewhere in the passed string.