Created
September 17, 2017 13:05
-
-
Save gooderist/ddd1f7049852931d1f491b7b7f35668a to your computer and use it in GitHub Desktop.
Simple English detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unicode = { | |
basic_latin: /[\u0020-\u007F]/g | |
} | |
console.log('賛美歌い続ける'.search(unicode.basic_latin)) // -1 | |
console.log('Sanbi utaitsuzukeru'.search(unicode.basic_latin)) // 0 | |
console.log('10,000 Reasons'.search(unicode.basic_latin)) // 0 | |
console.log('Bless the Lord oh my soul'.search(unicode.basic_latin)) // 0 | |
/* | |
We have English and Japanese lyrics in our church services and I needed | |
a quick way to differentiate between the two in a script I use for | |
slide generation. We never mix the two in the same line. | |
Tried using franc but it didn't work very well. | |
This is much simpler and does what we need. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment