![]() |
Yes, '?' is a special sign in regular expressions language that means, that preceding symbol can be in string, or can be omitted. You need to escape it by '\' to use as a string.
To replace many question marks by some string use the following regex: '/\?{3,}/' => '???' The expression in {} tells, that preceding symbol is repeated three or more times. We can write {,3} for example and it will mean, that something repeated up to three times. We can specify {3,6} and it will mean, that something is repeated from 3 to 6 times. dot (".") means one any symbol. plus ("+") means, that preceding symbol or expression is repeated one or more times. It is actually equal to {1,}. asterisk ("*") means, that preceding symbol or expression is repeated zero or more times. \d - means one any digit. \s - means any space character For example we can replace multiple spaces by one: '/\s+/' => '' " - remember, + means "one or more" If you need to apply + or * or any other "quantifier" to several characters you need to put these characters into brackets: /(abc)+/ => "abc" - replace one or more abc sttrings by one copy so that "abcabcabc" becomes "abc" So, about your case - yes, all correct, just escape ? by \ |
Got it, thanks so much!
One question, since I can't test this until my site goes live... does this work in post preview, or just when they submit the post? |
Actually, censor makes no changes to DB. So, words are replaced on post is displayed.
Preview is not affected preventing users from experimenting with filter faking. |
Hi!
Tell me please, is it possible to censor/replace the whole message, if it contains unwanted word? Thanks ) |
Quote:
|
Quote:
'/.*UnwantedWord.*/' => 'I don't like this message!' |
Interesting concept and one our forums could benefit from if the follow works as desired.
What would happen if you wanted to replace the "U" with "You" in the following sentence: "U should bring an umbrella." Would the outcome be "You should bring an umbrella." or You shoyould bring an youmbrella."? |
This is working nicely, thank you!
How would I have it reduce "?!?!?!?!?" to just "?!" I kno wmy members will 'get around' it by alternating them. :P |
Quote:
/\w+u\w+/ =>"you" \w - is any "non-word" character Quote:
"/((\?\!)|(\!\?))+/" = > "?!" It means, replace any number of "?!" or "!?" sequences by single "?!". "|" - means "or" Small update: to prevent users from using different combinations of "!", "?" and spaces one may try something like this: "/((\!\s*)|(\?\s*)){3,}/" => "Exclamation!" |
Quote:
But i have the same problem as brandondrury :( same mistakes and no messages on my forum shown at all. |
All times are GMT. The time now is 07:24 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|