----- Original Message ----- 
From: Mike Brandonisio 
Hi Bob,

How do you deal with "500 or more "X"s with no spaces"?
================================

Hi Mike,
My last regex about this wouldn't have worked.
I thought I'd reproduce it just as an exercise. It's really overkill and took 
it off, but it does seem to work. I couldn't ban the IP (must have been from a 
group of lads as they plaqued me for ages) but they tired after I put this on 
:-)

<?php
//just a test program
if ($_POST['submit'] == "Submit") {
  $result = array();
  //used own array instead of looped thro ASCII code. Note: dot needs escaping 
in array
  $char = 
array('-','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9',"'",'"',',','\.','
 ');
  //kill everything accept these
  $raw = preg_replace('/[^-A-Za-z0-9\'\"\,\.\r\n ]/', '', $_POST['raw']);
  $raw = nl2br($raw);
  $raw = explode(' ', $raw);
  foreach ($raw as $word) {
    foreach ($char as $x) {
      $word = preg_replace("/($x){3,}/i", '$1$1', $word);
    }
    $result[] = $word;
  }
  $result = implode($result, ' ');
  echo $result;
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<textarea name="raw" cols="50" rows="5"></textarea>
<input type="submit" name="submit" value="Submit" />
</form>

Regards, Bob E.



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to