ConsoleTVs / Profanity

PHP library to block bad words in a string
MIT License
98 stars 46 forks source link

Whole word matching option #3

Closed osappuk closed 6 years ago

osappuk commented 6 years ago

Hi,

Thank you for sharing the code. Is it possible to have whole word only matching option? For example, in my string there is a word "circumstances" and it is picked out by badWords() as "cum" :-( Thanks!

osappuk commented 6 years ago

It is really useless when a dictionary contain the word "ass" then the badWords() function picking out everything like: assess, classmates, assignment, etc.

Am I missing the usage of a flag to only filter whole word or is this package did not seriously consider this option? Please help, thanks!

ConsoleTVs commented 6 years ago

Done in 2.0.0

as ->strict(true/false) and ->strictClean(true/false). Both documented on the main page. Cheers!

osappuk commented 6 years ago

I am not sure what is wrong but I carefully test V2.0.0 but the badWords() function return empty array while there are definitely bad words :( Could you have a look, please. Thanks!

ConsoleTVs commented 6 years ago

image

image

Seems to be working for me :o

osappuk commented 6 years ago

Ah, I know why. It is because we did not convert strings to lowercase before comparison in here: in_array($value['word'], $words) . Could you please fix that? Thank you!

ConsoleTVs commented 6 years ago

Fixed