| 
	
 | 
 Posted by Toby A Inkster on 02/25/07 23:04 
Yorian wrote: 
 
> However this didn't work, even if I try to just replace the dollar 
> sign (by a b) it doesn't work properly: 
>  
> preg_replace("/\$/", "b", $string); 
 
You need to either use single-quote marks, or double-escape it. 
 
	"/\\\$/" 
	'/\$/' 
 
This is because the dollar sign has two special meanings in this case. 
Dollar signs in double-quotes are used by PHP for interpolation, so need 
escaping. Dollar signs in PCREs are used to mark the end of a string, so 
need escaping. Hence the double-escape. (i.e. three slashes!)  
 
--  
Toby A Inkster BSc (Hons) ARCS 
Contact Me ~ http://tobyinkster.co.uk/contact 
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux 
 
* = I'm getting there!
 
  
Navigation:
[Reply to this message] 
 |