Re: [PHP] Exact string replacement...

2002-02-09 Thread Desikan

hi there,
Have u tried this...
  ?php
$string = 'foo';
print preg_replace(/^\s$string\s/,' ','bfoo foo foobar.') . \n;
print eregi_replace(^[[:space:]].$string.[[:space:]],' ','bfoo
foo alfoobar.') . \n;
  ?
This is not working properly..

Output I got is

bfoo foo foobar. bfoo foo alfoobar

help me out

Rgds,
Desikan


On Sat, 9 Feb 2002 03:01:40 -0500, Brian Clark [EMAIL PROTECTED]
said:
 * Desikan ([EMAIL PROTECTED]) [Feb 09. 2002 02:52]:
 
  hi Thanks,
 
 Sure, 
 
But I want to do thr replace operation for 
regular exprerssion and not exactly for the string alone...
like ^and$,a*, etc
 
 ?php
 
 $string = 'foo';
 print preg_replace(/^\s$string\s/,' ',' foo foobar.') . \n;
 print eregi_replace(^[[:space:]].$string.[[:space:]],' ',' foo
 foobar.') . \n;
 
 ?
 
 I like the top better..
 
 -- 
 Headers set. CCs on list replies - bit bucket.
 Brian Clark | Unable to leap tall buildings in a single bound.
 Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
  Desikan
  [EMAIL PROTECTED]

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




Re: [PHP] Exact string replacement...

2002-02-09 Thread Brian Clark

* Desikan ([EMAIL PROTECTED]) [Feb 09. 2002 03:33]:

 hi there,

Backatcha,

 Have u tried this...
   ?php
 $string = 'foo';
 print preg_replace(/^\s$string\s/,' ','bfoo foo foobar.') . \n;
 print eregi_replace(^[[:space:]].$string.[[:space:]],' ','bfoo
 foo alfoobar.') . \n;
   ?
 This is not working properly..

 Output I got is

 bfoo foo foobar. bfoo foo alfoobar

You do realize that ^ is matching the beginning of a string, right?

Take out the ^ in each and you'll get the correct result.

 help me out

Hope that helps.

-- 
Headers set. CCs on list replies - bit bucket.
Brian Clark | The land of the free, and the home of the brave.
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8


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




Re: [PHP] Exact string replacement...

2002-02-08 Thread Brian Clark

* Desikan ([EMAIL PROTECTED]) [Feb 09. 2002 02:17]:

 Hi there,

Hi,

 Please help me out in the following...

 ?php
 $is='is';
 echo eregi_replace( .$is. , ,This is a test string which contains
 is in dismissal);
 ?


 Actually I want to replace is alone from the string and not all the
 words that contains is...

str_replace() would be easier:

?php

$string = ' foo ';
print str_replace($string,' nude ','This is a foo bar.');

?

-- 
Headers set. CCs on list replies - bit bucket.
Brian Clark | Unable to leap tall buildings in a single bound.
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8


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




Re: [PHP] Exact string replacement...

2002-02-08 Thread Brian Clark

* Desikan ([EMAIL PROTECTED]) [Feb 09. 2002 02:52]:

 hi Thanks,

Sure, 

   But I want to do thr replace operation for 
   regular exprerssion and not exactly for the string alone...
   like   ^and$,a*, etc

?php

$string = 'foo';
print preg_replace(/^\s$string\s/,' ',' foo foobar.') . \n;
print eregi_replace(^[[:space:]].$string.[[:space:]],' ',' foo foobar.') . \n;

?

I like the top better..

-- 
Headers set. CCs on list replies - bit bucket.
Brian Clark | Unable to leap tall buildings in a single bound.
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8


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