Skip to content

Instantly share code, notes, and snippets.

@swedesjs
Last active June 17, 2021 20:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swedesjs/c127bd33c6d8c22e3e217d70c9494b07 to your computer and use it in GitHub Desktop.
Save swedesjs/c127bd33c6d8c22e3e217d70c9494b07 to your computer and use it in GitHub Desktop.
Class Swearing-Detector
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('я твою мать ебал хуила'))
@KR1470R
Copy link

KR1470R commented Jun 2, 2021

image
криво работает

@swedesjs
Copy link
Author

image
криво работает

Потом поправлю, времени нема

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment