Pangram validator in one line
source link: https://christianheilmann.com/2023/11/06/pangram-validator-in-one-line/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Pangram validator in one line
Monday, November 6th, 2023 at 2:36 pm
For a quiz, I am playing with Pangrams, sentences that have all 26 letters of the alphabet in them. Using Set and some RegEx it is a one-liner in JavaScript to validate them (split into two lines for readability…).
const isPangram = s => new Set( s.toLowerCase().replace(/[^a-z]/g, '') ).size === 26; |
I’ve also put together a small tool for myself to write pangrams and check them whilst I type. You can see it in action here:
Do you have a shorter solution?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK