[Tutorial] Banning CAPSLOCK / shouting in posts
#7
Turns out I'd deleted it, but it was easy enough to figure out the code again. Ignore the comments, it's part of a project I'm working on. Smile

// Do a tad of fancy examination
			if((strlen($message) / 2) < strlen(preg_replace('![^A-Z]+!', '', $message)))
			{
				// Half the message is uppercase.
				// User is (probably) trying to SHOUT.
				$message = ucfirst(strtolower($message));
			}

Notes:
- This is slightly more reliable than the OP, as with that, a single punctuation mark can cause it not to parse.
- Sentences will lack grammar correction: I's will not be capitalized, and new sentences aren't capitalized. It's probably possible to do both, but this is a very basic example.
Please don't PM me for support. Smile
Reply


Messages In This Thread
RE: [Tutorial] Banning CAPSLOCK / shouting in posts - by Krytic - 2013-03-31, 04:30 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)