Re: [PHP] Help w/ regular expressions for banned words

2001-01-20 Thread Team JUMP

No, it didn't work.  I've tried [:space:]$bannedwords[$i][:space:],
\<$bannedwords[$i]\>, and \b$bannedwords[$i]\b.  It doesn't detect anything.
I'm reading a list of banned words out of a text file and putting them into
$bannedwords.  I'm pretty sure $bannedwords is right, since I've tried stuff
like "test" (detected), "\" (not detected), "[:space:]test[:space:]"
(not detected).

And, in all times, I use the syntax like this: $string =
eregi_replace("a","[censored]",$string);

So I'm sure the syntax is right.

Thanks for your help, though.

--Neal




---


did it work?

- Original Message -
From: Team JUMP <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 20, 2001 12:35 PM
Subject: Re: [PHP] Help w/ regular expressions for banned words


Thanks for your help.  Unfortunately, [:space:]$bannedwords[$i][:space:]
would not work, since I need to also check for the first and last word.  In
a last-case scenario I could write special code for the first and last word,
but that may get ugly with bug-checking... but I've already tried
"\s+$bannedwords[$i]\s+" to no avail.  I believe [:space:] is just a
substitute for \s+, right?

Yeah, I've tried \<$bannedwords[$i]\> too, unfortunately.  Like I said
before, eregi_replace("a","[censored]",$string) makes a match, but
eregi_replace("\","[censored]",$string) or
eregi_replace("\ba\b","[censored]",$string) does not.  Most odd.

Thanks for your help, though.  Anyone else have suggestions?

--Neal





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Help w/ regular expressions for banned words

2001-01-20 Thread Romulo Roberto Pereira

try this; I am working on the last word... ereg replace is not finding the
REGEX "\.$" - anyone has a clue?

";
echo $string."";
 for($i=0;$i<$num;$i++) {
  $string = eregi_replace("{$bannedwords[$i]}","[censored]",$string);
 }
*/
echo $string."";

// take out the damn ; . : chars on the end of the string and save for later
/*
 elseif (ereg("\;$",$string)) {
 ereg_replace("\;$","",$string);
 $semmicolon = TRUE;
} elseif (ereg("\:$",$string)) {
 ereg_replace("\:$","",$string);
 $colon = TRUE;
} else {
 $dot = TRUE;
 $semmicolon = TRUE;
 $colon = TRUE;
}
*/
$hasdot = ereg("\.$",$string);

if ($hasdot) {
 ereg_replace("\.$","test",$string);
 $dot = TRUE;
}

// the middle words
 reset($bannedwords);
 foreach ($bannedwords as $word) {
  $string = eregi_replace(" {$word} "," [censored] ",$string);
 }

echo $string."";

// test the start word and exchange
 reset($bannedwords);
 foreach ($bannedwords as $word) {
  $string = eregi_replace("^{$word}","[censored] ",$string);
 }

echo $string."";

// test the end word and exchange
 reset($bannedwords);
 foreach ($bannedwords as $word) {
  $string = eregi_replace("{$word}$","[censored]",$string);
 }

echo $string."";
echo $dot."";
echo $hasdot;
?>

- Original Message -
From: Team JUMP <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 20, 2001 12:35 PM
Subject: Re: [PHP] Help w/ regular expressions for banned words


Thanks for your help.  Unfortunately, [:space:]$bannedwords[$i][:space:]
would not work, since I need to also check for the first and last word.  In
a last-case scenario I could write special code for the first and last word,
but that may get ugly with bug-checking... but I've already tried
"\s+$bannedwords[$i]\s+" to no avail.  I believe [:space:] is just a
substitute for \s+, right?

Yeah, I've tried \<$bannedwords[$i]\> too, unfortunately.  Like I said
before, eregi_replace("a","[censored]",$string) makes a match, but
eregi_replace("\","[censored]",$string) or
eregi_replace("\ba\b","[censored]",$string) does not.  Most odd.

Thanks for your help, though.  Anyone else have suggestions?

--Neal



on 1/20/01 12:20 PM, CC Zona at [EMAIL PROTECTED] wrote:

> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> (Team JUMP) wrote:
>
>> $num=count($bannedwords);
>> for($i=0;$i<$num-1;$i++)
>> {
>> $string =
>> eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
>> }
>>
>>
>> For whatever reason, no word in $bannedwords will match in the string.
I've
>> tested it with simple expressions like "\btest\b" and it will not match
the
>> word "test".
>
> Have you tried it with either "[:space:]$bannedwords[$i][:space:] or
> "\<$bannedwords[$i]\>" yet?  Also, I think using a foreach($bannedwords as
> $current_word) would be a better choice here; more compact, and loops all
> the way to the end of the array even when the numerical index does not
> follow the expected sequence.  (BTW, if you want to stick with the for()
> and you know the index numbers will always be sequentially zero to
> whatever, then your test should be just $i<$num.  Otherwise, you're
> skipping the final loop.)




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Help w/ regular expressions for banned words

2001-01-20 Thread Team JUMP

Thanks for your help.  Unfortunately, [:space:]$bannedwords[$i][:space:]
would not work, since I need to also check for the first and last word.  In
a last-case scenario I could write special code for the first and last word,
but that may get ugly with bug-checking... but I've already tried
"\s+$bannedwords[$i]\s+" to no avail.  I believe [:space:] is just a
substitute for \s+, right?

Yeah, I've tried \<$bannedwords[$i]\> too, unfortunately.  Like I said
before, eregi_replace("a","[censored]",$string) makes a match, but
eregi_replace("\","[censored]",$string) or
eregi_replace("\ba\b","[censored]",$string) does not.  Most odd.

Thanks for your help, though.  Anyone else have suggestions?

--Neal



on 1/20/01 12:20 PM, CC Zona at [EMAIL PROTECTED] wrote:

> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> (Team JUMP) wrote:
> 
>> $num=count($bannedwords);
>> for($i=0;$i<$num-1;$i++)
>> {
>> $string =
>> eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
>> }
>> 
>> 
>> For whatever reason, no word in $bannedwords will match in the string.  I've
>> tested it with simple expressions like "\btest\b" and it will not match the
>> word "test". 
> 
> Have you tried it with either "[:space:]$bannedwords[$i][:space:] or
> "\<$bannedwords[$i]\>" yet?  Also, I think using a foreach($bannedwords as
> $current_word) would be a better choice here; more compact, and loops all
> the way to the end of the array even when the numerical index does not
> follow the expected sequence.  (BTW, if you want to stick with the for()
> and you know the index numbers will always be sequentially zero to
> whatever, then your test should be just $i<$num.  Otherwise, you're
> skipping the final loop.)




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Help w/ regular expressions for banned words

2001-01-20 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
(Team JUMP) wrote:

>$num=count($bannedwords);
> for($i=0;$i<$num-1;$i++)
> {
> $string =
> eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
> }
> 
> 
> For whatever reason, no word in $bannedwords will match in the string.  I've
> tested it with simple expressions like "\btest\b" and it will not match the
> word "test". 

Have you tried it with either "[:space:]$bannedwords[$i][:space:] or 
"\<$bannedwords[$i]\>" yet?  Also, I think using a foreach($bannedwords as 
$current_word) would be a better choice here; more compact, and loops all 
the way to the end of the array even when the numerical index does not 
follow the expected sequence.  (BTW, if you want to stick with the for() 
and you know the index numbers will always be sequentially zero to 
whatever, then your test should be just $i<$num.  Otherwise, you're 
skipping the final loop.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Help w/ regular expressions for banned words

2001-01-20 Thread Team JUMP

$num=count($bannedwords);
for($i=0;$i<$num-1;$i++)
{
$string =
eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
}


For whatever reason, no word in $bannedwords will match in the string.  I've
tested it with simple expressions like "\btest\b" and it will not match the
word "test".  Does it have something to do with the 2 "\b"s found in the
code?  After removing them, it replaces all instances of $bannedwords, even
in the middle of words, which is not good.  Any suggestions?


TIA,

Neal


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]