PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Troubleshooting (http://www.phpdig.net/forum/forumdisplay.php?f=22)
-   -   Warning: ereg_replace(): REG_EBRACK in ..... (http://www.phpdig.net/forum/showthread.php?t=1596)

Jad 12-10-2004 02:45 AM

Warning: ereg_replace(): REG_EBRACK in .....
 
Greetings
I'm getting this error while spidering
Warning: ereg_replace(): REG_EBRACK in /full/path/to/libs/phpdig_functions.php on line 231

$text = ereg_replace('(['.$phpdig_words_chars[$encoding].'])[\'._~@#$:&%/;,=-]+
($|[[:space:]]$|[[:space:]]['.$phpdig_words_chars[$encoding].'])','\1\2',$text);

I have replaced ereg_replace with str_replace and it works fine
now phpDig works fine, but why it was giving errors with ereg_replace?

Charter 12-10-2004 12:19 PM

If you set your encoding to iso-8859-1, then you should crawl pages with the same encoding. It is not advisable to replace ereg_replace with str_replace! Try the below test.
PHP Code:

<?php
error_reporting
(E_ALL);
$text "abc 123 '\"._~@#$:&%/;,=- [abc] AÀÁÂÃÄÅ [123] ðþßµ";
define('PHPDIG_ENCODING','iso-8859-1');
$phpdig_words_chars['iso-8859-1'] = '[:alnum:]ðþßµ';
$encoding PHPDIG_ENCODING;
$text ereg_replace('[^'.$phpdig_words_chars[$encoding].' \'._~@#$:&%/;,=-]+',' ',$text);
$text ereg_replace('(['.$phpdig_words_chars[$encoding].'])[\'._~@#$:&%/;,=-]+($|[[:space:]]$|[[:space:]]['.$phpdig_words_chars[$encoding].'])','\1\2',$text);
echo 
$text// prints abc 123 ' ._~@#$:&%/;,=-  abc  A   123  ðþßµ
?>


Jad 12-11-2004 09:57 PM

hmm I can understand but the problem, I'm crawling sites with different encoding, I have tried to use UTF-8 (I though I first that phpDig Convert and store data to the selected encoding )
but it didnt work fine, and same with other encoding
what to do when I have to crawl sites with different encoding ?

vinyl-junkie 12-11-2004 11:58 PM

Quote:

Originally Posted by Jad
what to do when I have to crawl sites with different encoding ?

The only thing you can do is change the encoding each time you want to crawl a different site. It's a pain, I know, but it will work for you.


All times are GMT -8. The time now is 11:20 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.