Javascript Pangram Regex [英] Javascript Pangram Regex

查看:100
本文介绍了Javascript Pangram Regex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个REGEX来测试PANGRAM。我可以用传统的方式做到这一点,但似乎无法通过正则表达式来解决90%以上的测试。

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.

输入:字符串

输出:true || false

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
/ [az] {1} / i

6/10 / [az ] / i

6/10 / [az] + / 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
仅对 abcdefghijklmopqrstuvwxyz

6/10 / [\ w。] + /

非常感谢任何帮助或建议。

Any help or advice is greatly appreciated.

推荐答案

这将是一个正确的答案挑战:

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.

这篇关于Javascript Pangram Regex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆