Created
November 26, 2022 04:20
-
-
Save weaponsforge/66f970324ba0f97f1402022d2be55c9e to your computer and use it in GitHub Desktop.
js tokenizer
This file contains 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 string = 'Hello, World!' | |
// Split the a string into words while removing special characters | |
const words = string.replace(/[!@#$%^&*()_+\-=\[\]{};:"\\|,.<>\/?]/g, '').split(' ').filter(x => x.match(/[a-z]/g)) | |
console.log(words) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment