Replacement & Censorship System

The Replacement & Censorship System allows the administrator to replace certain strings in the messages, signatures and biographies of the users with another text string.

The most common use of this system is to censor certain words and phrases that the admin feels are in appropriate for the forum. For this purpose FUDforum 2.3 offers two syntaxes for replacing text ranging from a simple replace to a complex regular expression.

String Replace

The most basic and the easiest to use string replacement option is "String Replace". This option will allow you to specify the 'Replace' string with its alternative the 'With' string. For example, if you specify the replace string as "haystack" and it's alternative as needle then

this haystack is sharp.
will be converted to:
this needle is sharp.

Perl Regex

Perl Regex will use a perl regular expression library to perform a replacement on a text or a text mask. This although slower then str_replace it allows for a much more powerful and sophisticated text manipulation.

Note

This functionality uses PHP's PECL library and utilize the preg_replace function. PHP's documentation of this function and its capabilities & syntax can be found here.

Lets say, you want to replace all words containing the string 'spoon' with 'fork'. Clearly you cannot use String Replace for this because it would not replace the entire word but only the 'spoon' part. For this purpose you need to use the power of regular expressions.

Inside the 'Replace' field we enter the

!(\s|^)([^\s]*?)spoon([^\s]*?)(\s|$)!i
regular expression and enter
\1fork\4
as the 'With' alternative. The end result of this regex that any word containing the string 'spoon' will be replaced with "fork". Because we've added the 'i' parameter to our regex, which made it case-insensitive, so even the "SpOon" instances will be found and replaced.

Because the regular expression is generally rather complex there is no easy way FUDforum 2.3 can figure out how to reverse it back, so that when the person is editing their text they can see the text that they have originally entered. Therefor you get 2 extra fields ('From post' and 'To')were you get to specify the "reverse" regex that would convert the replaced data back its original form. Based on the previous example involving "fork" & "spoon" the conversion back strings would look like this:

From post:	!(\s|^)fork(\s|$)!
To:		spoon

Note

The messages & signatures entered prior the the addition of a replace will not be affected by the newly added replace syntax.