This is a simple project that filters out profane words using regex in PHP. It provides functions to check, get, mask, and remove unwanted words from a text using regex patterns that account for similar characters.
-
Run the following command in your project directory:
composer require kamu/aman
-
How to Add Blocklist or Allowlist Words
// Add words to the blocklist Aman::extend(['oke', 'safe']); // Add words to the whitelist Aman::allow(['oke', 'safe']);
-
Check for Profane Words
use Kamu\Aman; $text = "This is an example with bad words."; $filter = Aman::factory(); if ($filter->check($text)) { echo "This text contains profanity."; } else { echo "This text is clean."; }
-
Mask Profane Words
$text = "This is an example with bad words."; $maskedText = $filter->masking($text, '*'); echo $maskedText; // Output: "This is an example with *** ****."
-
Remove Profane Words
$text = "This is an example with bad words."; $cleanText = $filter->filter($text); echo $cleanText; // Output: "This is an example with ."
-
Get Profane Words from Text
$text = "This is an example with bad words."; $badWords = $filter->words($text); print_r($badWords); // Output: ['bad', 'words']
I'm very open to those of you who want to contribute to the Aman!
If you find any security vulnerabilities in this Aman, please email DKL via dewanakretarta29@gmail.com.
Aman is open-sourced software licensed under the MIT license.