Quote:
Originally posted by JBMoney
Radgam - It's working a lot better for me without these last two lines:
$response = preg_replace("/(\?|\.|!)(\w)/" , " $1", $response );
$response = preg_replace("/(\w)\s+(\w|\?|\.|!)/","$1 $2",$response);
They seem to be causing all the punctuation related problems I mentioned.
|
that's weird

It's just a basic find/replace, it shouldn't be cutting off any characters... I tested it throughly on my localhost before posting as well :dead:
Could be the different OS i guess. The problem i found (just for example) is when you say "my favourite movie is lord of the rings" and you get a ton of white space.
I'll test the code a bit more and let you know what i find.
edit: oooo, i very much appologise for my mistake in the original post. I forgot to include the $2 variable which contains the word in the find/replace
Here is the updated version, please let me know if it works :nervous: (and yes, i know it's quite a few searches, but they need to be seperate to function properly :/ - but it has cleaned the output very well on my board (and is based on heavy testing!!)
Code:
Find:
$ttb_time = time() + rand(1,5);
After that line add:
// Clean Output
$response = str_replace('<br>' , '', $response );
$response = str_replace('</br>' , '', $response );
$response = str_replace(', .' , '.', $response );
$response = preg_replace("/(\?|\.|!)(\w)/","$1 $2",$response);
$response = preg_replace("/(\w|,)\s+(\w|\?|\.|!)/","$1 $2",$response);
$response = preg_replace("/\n\s+/","\n",$response);