Last active
June 17, 2021 20:08
-
-
Save swedesjs/c127bd33c6d8c22e3e217d70c9494b07 to your computer and use it in GitHub Desktop.
Class Swearing-Detector
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 test = (text) => | |
preg_match_all( | |
new RegExp( | |
` | |
[\\p{L}\\p{N}]* | |
( | |
\\w*[пПnPp][иИiI1uеЕeE][зЗ3zZ3][дДdD]\\w* | |
| | |
(?:[^иИiI1uуУyYuU\s]+|нНhHиИiI1u)?(?<!стра)[хХxXhH][уУyYuU][йЙyеЕeEяЯёЁиИiI1uлЛlLюЮ](?!иг)\\w* | |
| | |
\\w*[бБ6bB][лЛlL](?: | |
[яЯ]+[дДdDтТtT]? | |
| | |
[иИiI1u]+[дДdDтТtT]+ | |
| | |
[иИiI1u]+[аАaA]+ | |
)(?!х)\\w* | |
| | |
(?: | |
\\w*[йЙyуУyYuUеЕeEаАaAоОoO0ъЪьЬыЫяЯ][еЕeEёЁяЯиИiI1u][бБ6bBпПnPp](?!ы\b|ол)\\w* | |
| | |
[еЕeEёЁ][бБ6bB]\\w* | |
| | |
[иИiI1u][бБ6bB][аАaA]\\w+ | |
| | |
[йЙy][оОoO0][бБ6bBпПnPp]\\w* | |
) | |
| | |
\\w*[сСcCsS][цЦcC]?[уУyYuU]+(?: | |
[чЧ4]*[кКkK]+ | |
| | |
[чЧ4]+[кКkK]* | |
)[аАaAоОoO0]\\w* | |
| | |
\\w*(?: | |
[пПnPp][иИiI1uеЕeE][дДdD][аАaAоОoO0еЕeE]?[рРpPrR](?!о)\\w* | |
| | |
[пПnPp][еЕeE][дДdD][еЕeEиИiI1u]?[гГgGкКkK] | |
) | |
| | |
\\w*[зЗ3zZ3][аАaAоОoO0][лЛlL][уУyYuU][пПnPp]\\w* | |
| | |
\\w*[мМmM][аАaA][нНhH][дДdD][аАaAоОoO0]\\w* | |
)` | |
.replace(/\s/g, '') | |
.replace(/\n/g, ''), | |
'i' | |
), | |
text | |
) | |
function preg_match_all(regex, haystack) { | |
'use strict' | |
let globalRegex = new RegExp(regex, 'g'), | |
nonGlobalRegex = new RegExp(regex), | |
nonGlobalMatch, | |
globalMatch = haystack.match(globalRegex), | |
matchArray, | |
i | |
matchArray = [] | |
for (i = 0; i < globalMatch.length; i += 1) { | |
nonGlobalMatch = globalMatch[i].match(nonGlobalRegex) | |
matchArray.push(nonGlobalMatch[1]) | |
} | |
return matchArray | |
} | |
console.log(test('я твою мать ебал хуила')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
криво работает