Its giving me a styling nightmare when someone chucks in something with a consecutive string of greater than 60 characters
Forum Consecutive Character Problem !
Moderator: General Moderators
Forum Consecutive Character Problem !
I'm sure this must have been touched on before but I can't find an example of it - Does anyone know the regular expression to limit the number of conseuctive non breaking characters (i.e a string not including spaces or breaks) to a certain number?
Its giving me a styling nightmare when someone chucks in something with a consecutive string of greater than 60 characters

Its giving me a styling nightmare when someone chucks in something with a consecutive string of greater than 60 characters
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Thanks for the reply Everah, yep that would be the easy thing to do but i don't want to limit the title length (or even the message body length).
I was wondering if someone had a regular expression written for this very problem:
opppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

I was wondering if someone had a regular expression written for this very problem:
opppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Give this a try.. haven't tested or used it though..
Code: Select all
// textwrap 1.1 Brian Moon <brian@phorum.org>
// This code is part of the Phorum project <http://phorum.org>
// $String The string to be wrapped.
// $breaksAt How many characters each line should be.
// $breakStr What character should be used to cause a break.
// $padStr Allows for the wrapped lines to be padded at the begining.
function textwrap ($String, $breaksAt = 78, $breakStr = "\n", $padStr="") {
$newString="";
$lines=explode($breakStr, $String);
$cnt=count($lines);
for($x=0;$x<$cnt;$x++){
if(strlen($lines[$x])>$breaksAt){
$str=$lines[$x];
while(strlen($str)>$breaksAt){
$pos=strrpos(chop(substr($str, 0, $breaksAt)), " ");
if ($pos == false) {
break;
}
$newString.=$padStr.substr($str, 0, $pos).$breakStr;
$str=trim(substr($str, $pos));
}
$newString.=$padStr.$str.$breakStr;
}
else{
$newString.=$padStr.$lines[$x].$breakStr;
}
}
return $newString;
} // end textwrap()