[PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread -{ Rene Brehmer }-
Never mind y'all ... me stupid ...

obviously the ( has meaning, and needs to be escaped ... was starting to 
think it could only do 2 ereg's in 1 script *sigh*

Sorry for wasting time and bandwidth ... the function now looks like this 
and works :

function gfx_smiley($text) {
  $smiley_path = 'smiley';
  $text = eregi_replace(':-?D','img src='.$smiley_path.'/biggrin.gif 
alt=:D width=15 height=15 align=absmiddle',$text);
  $text = ereg_replace(':-?\?','img src='.$smiley_path.'/confused.gif 
alt=:? width=15 height=22 align=absmiddle',$text);
  $text = ereg_replace(':#039;-?\(','img 
src='.$smiley_path.'/crying.gif alt=:#039;( width=25 height=15 
align=absmiddle',$text);
  $text = ereg_replace(':-?\(','img src='.$smiley_path.'/frown.gif 
alt=:( width=15 height=15 align=absmiddle',$text);

  return $text;
}
At 15:43 14-04-2004, -{ Rene Brehmer }- wrote:
I'm trying to do graphical smileys for my guestbook, but I've run into a 
problem with the crying smilies:

I need to replace :'( and :'-( ... or as they look in the post after being 
entered through htmlentities with ent_quotes on:

:#039;(
:#039;-(
this causes the entire message to disappear:

$text = ereg_replace(':#039;-?(','img src='.$smiley_path.'/crying.gif 
alt=:#039;( width=25 height=15 align=absmiddle',$text);

only the format of the search part differs from my other smiley 
replacements, so obviously that's where the problem is ... afaik, neither 
, # or ; have any meaning in regex, so I don't get what causes it ... 
I've tried escaping all of those chars, and it still causes $text to come 
back empty...

any ideas will be highly appreciated...
--
Rene Brehmer
aka Metalbunny
~ If you don't like what I have to say ... don't read it ~

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums @ http://forums.metalbunny.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread Tom Rogers
Hi,

Thursday, April 15, 2004, 12:51:20 AM, you wrote:
RB Never mind y'all ... me stupid ...

RB obviously the ( has meaning, and needs to be escaped ... was starting to
RB think it could only do 2 ereg's in 1 script *sigh*

RB Sorry for wasting time and bandwidth ... the function now looks like this
RB and works :


You might find this very useful :)

http://weitz.de/regex-coach/

Helps my old brain 

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread -{ Rene Brehmer }-
At 15:02 14-04-2004, Tom Rogers wrote:
Hi,

Thursday, April 15, 2004, 12:51:20 AM, you wrote:
RB Never mind y'all ... me stupid ...
RB obviously the ( has meaning, and needs to be escaped ... was starting to
RB think it could only do 2 ereg's in 1 script *sigh*
RB Sorry for wasting time and bandwidth ... the function now looks like this
RB and works :
You might find this very useful :)

http://weitz.de/regex-coach/

Helps my old brain 
Hmm ... that looks like it only does Perl-based regex ???  Thing is the 
programs I normally do regex in either use Posix based or Unix (Cshell) 
based (mostly used at the latter, cuz that's what Forte Agent uses for its 
filters) ... how big a difference is there from the posix based to the perl 
based anyway ??? ... the samples in the manual ain't the same for 
preg_replace() and ereg_replace(), so it's a bit hard to get a quick 
glimpse of how big the difference really is ... (or for the _match() ones 
for that matter)...

But thx ... looks useful :)

Rene

--
Rene Brehmer
aka Metalbunny
~ If you don't like what I have to say ... don't read it ~

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums @ http://forums.metalbunny.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re[2]: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread Tom Rogers
Hi,

Thursday, April 15, 2004, 8:56:05 AM, you wrote:
RB At 15:02 14-04-2004, Tom Rogers wrote:
Hi,

Thursday, April 15, 2004, 12:51:20 AM, you wrote:
RB Never mind y'all ... me stupid ...

RB obviously the ( has meaning, and needs to be escaped ... was starting to
RB think it could only do 2 ereg's in 1 script *sigh*

RB Sorry for wasting time and bandwidth ... the function now looks like this
RB and works :


You might find this very useful :)

http://weitz.de/regex-coach/

Helps my old brain 

RB Hmm ... that looks like it only does Perl-based regex ???  Thing is the
RB programs I normally do regex in either use Posix based or Unix (Cshell)
RB based (mostly used at the latter, cuz that's what Forte Agent uses for its
RB filters) ... how big a difference is there from the posix based to the perl
RB based anyway ??? ... the samples in the manual ain't the same for 
RB preg_replace() and ereg_replace(), so it's a bit hard to get a quick
RB glimpse of how big the difference really is ... (or for the _match() ones
RB for that matter)...

RB But thx ... looks useful :)


RB Rene

RB -- 
RB Rene Brehmer
RB aka Metalbunny

RB ~ If you don't like what I have to say ... don't read it ~

RB http://metalbunny.net/
RB References, tools, and other useful stuff...
RB Check out the new Metalbunny forums @ http://forums.metalbunny.net/

Yes it is based on perl regular expressions which are pretty close to
posix, close enough for simple stuff anyway.
preg_replace is quite a bit faster than ereg_replace, I know preg_*
functions keep a cache of expressions which can speed up repetitive
uses. Not sure about ereg functions though.

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread Curt Zirzow
* Thus wrote Tom Rogers ([EMAIL PROTECTED]):
 Hi,
 
 Thursday, April 15, 2004, 8:56:05 AM, you wrote:
 RB At 15:02 14-04-2004, Tom Rogers wrote:
...

 RB preg_replace() and ereg_replace(), so it's a bit hard to get a quick
 RB glimpse of how big the difference really is ... (or for the _match() ones
 RB for that matter)...
 
 RB But thx ... looks useful :)
 
 
 Yes it is based on perl regular expressions which are pretty close to
 posix, close enough for simple stuff anyway.
 preg_replace is quite a bit faster than ereg_replace, I know preg_*
 functions keep a cache of expressions which can speed up repetitive
 uses. Not sure about ereg functions though.

From all benchmarks I've seen pcre beats posix hands down, not to
mention that pcre is much more powerful.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php