vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Show Thread Enhancements - FractalizeR: Extended Post Censor (https://vborg.vbsupport.ru/showthread.php?t=162548)

FractalizeR 11-14-2007 07:16 AM

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 \

Elenna 11-14-2007 12:34 PM

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?

FractalizeR 11-14-2007 01:55 PM

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.

mrkiwi 11-14-2007 02:50 PM

Hi!
Tell me please, is it possible to censor/replace the whole message, if it contains unwanted word?
Thanks )

Elenna 11-14-2007 04:23 PM

Quote:

Originally Posted by FractalizeR (Post 1382405)
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.

Awesome, thank you! That's what I was afraid of, if it happened during preview ;)

FractalizeR 11-14-2007 05:22 PM

Quote:

Originally Posted by mrkiwi (Post 1382446)
Hi!
Tell me please, is it possible to censor/replace the whole message, if it contains unwanted word?
Thanks )

Hi. Yes, actually, it is. Try to make it by such regex:

'/.*UnwantedWord.*/' => 'I don't like this message!'

tobybird 11-14-2007 05:23 PM

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."?

Elenna 11-15-2007 02:46 AM

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

FractalizeR 11-15-2007 05:29 AM

Quote:

Originally Posted by tobybird (Post 1382527)
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."?

In this case we need to change a single "u" with "you". You can try this one:
/\w+u\w+/ =>"you"
\w - is any "non-word" character

Quote:

Originally Posted by Elenna
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

Make it like:
"/((\?\!)|(\!\?))+/" = > "?!"
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!"

mrkiwi 11-15-2007 09:13 AM

Quote:

Originally Posted by FractalizeR (Post 1382526)
Hi. Yes, actually, it is. Try to make it by such regex:

'/.*UnwantedWord.*/' => 'I don't like this message!'

Thanks.

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
  • Page Generation 0.02086 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete