Explorar o código

php: fixed EReg.replace (issue 194)

Franco Ponticelli %!s(int64=15) %!d(string=hai) anos
pai
achega
a140fe7dcf
Modificáronse 2 ficheiros con 4 adicións e 2 borrados
  1. 2 1
      doc/CHANGES.txt
  2. 2 1
      std/php/_std/EReg.hx

+ 2 - 1
doc/CHANGES.txt

@@ -8,7 +8,8 @@
 	flash9 : fixed TypedDictionary.exists
 	flash9 : fixed TypedDictionary.exists
 	all : added @:build for enums
 	all : added @:build for enums
 	neko : Std.parseFloat now returns NaN with invalid string
 	neko : Std.parseFloat now returns NaN with invalid string
-	php: fixed Array.push must return the current length
+	php: fixed Array.push must return the current length (issue 219)
+	php: fixed EReg.replace (issue 194)
 
 
 2010-08-14: 2.06
 2010-08-14: 2.06
 	neko : change serializer to be able to handle instances of basic classes from other modules
 	neko : change serializer to be able to handle instances of basic classes from other modules

+ 2 - 1
std/php/_std/EReg.hx

@@ -81,9 +81,10 @@
 	}
 	}
 
 
 	public function replace( s : String, by : String ) : String {
 	public function replace( s : String, by : String ) : String {
+		by = untyped __call__("str_replace", "\\$", "\\\\$", by);
 		by = untyped __call__("str_replace", "$$", "\\$", by);
 		by = untyped __call__("str_replace", "$$", "\\$", by);
 		untyped __php__("if(!preg_match('/\\\\([^?].+?\\\\)/', $this->re)) $by = preg_replace('/\\$(\\d+)/', '\\\\\\$\\1', $by)");
 		untyped __php__("if(!preg_match('/\\\\([^?].+?\\\\)/', $this->re)) $by = preg_replace('/\\$(\\d+)/', '\\\\\\$\\1', $by)");
-		return untyped __php__("preg_replace")(re, by, s, global ? -1 : 1);
+		return untyped __call__("preg_replace", re, by, s, global ? -1 : 1);
 	}
 	}
 
 
 	public function customReplace( s : String, f : EReg -> String ) : String {
 	public function customReplace( s : String, f : EReg -> String ) : String {