Blasp is a Profanity Filter Package for Laravel
Last updated on by Paul Redmond
Blasp is a Laravel profanity filter package that helps detect and mask profane words. It provides profanity detection, substitution options, obfuscation, and more.
use Blaspsoft\Blasp\Facades\Blasp; $sentence = 'Laravel News kicks ass!';$blasp = Blasp::check($sentence); $blasp->getSourceString(); // "Laravel News kicks ass!"$blasp->getCleanString(); // "Laravel News kicks ***!"$blasp->hasProfanity(); // true$blasp->getProfanitiesCount(); // 1$blasp->getUniqueProfanitiesFound(); // ['ass']
Besides straight matches, this package also matches various like substitution (i.e., a$$
), obscured profanity (i.e., a-s-s
), repeated letters, and combinations of all of them. Along with the Blasp
facade, this package provides a validation rule you can use to validate form input for profanity:
$validated = $request->validate([ 'sentence' => ['blasp_check'],]); // If the sentence contains profanities, validation will fail.
You can learn more about this package, get full installation instructions, and view the source code on GitHub.