Created
August 27, 2018 19:06
-
-
Save iliyaZelenko/77494f5e3f4d26f30fdc750d2693d336 to your computer and use it in GitHub Desktop.
Find all words in text(regular expression)
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
function getWords (text) { | |
return text.match(/([^\u0000-\u0040\u005B-\u0060\u007B-\u00BF\u02B0-\u036F\u00D7\u00F7\u2000-\u2BFF])+/g) | |
} | |
// Example: | |
// For text: 'Есть button, h1, textarea. Мне нужно: найти самое длинное слово в-textarea! то -- что пишу в ней'.match(...) | |
// Result will be: ["Есть", "button", "h", "textarea", "Мне", "нужно", "найти", "самое", "длинное", "слово", "в", "textarea", "то", "что", "пишу", "в", "ней"] | |
// AUTOR: https://regexr.com/3b0ik |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment