note 110213 rejected from function.preg-replace by googleguy

From: Date: Wed, 03 Oct 2012 02:31:22 +0000
Subject: note 110213 rejected from function.preg-replace by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191107@lists.php.net to get a copy of this message
Note Submitter: andreob at gmail dot com ---- I'm reading a string from a file: '\tfirst\n\tsecond\n'. The string has 19 characters, \n are two characters, \t are two characters. I want to transform the two chars "\n" in one char "\n", the two "\t" in one "\t", and any char followed by \ in one char "\ANY_CHAR", using the preg_replace as following: preg_replace("/\\\\([\w])/", "\\\\\\1", $string); But it's not working. Somebody can help me?

« previous php.notes (#191107) next »