Browse Source

Lua: Do the $ escapes in Ereg manually, since Lua uses % for that

Justin Donaldson 9 years ago
parent
commit
e5549102a5
1 changed files with 2 additions and 1 deletions
  1. 2 1
      std/lua/_std/EReg.hx

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

@@ -114,7 +114,8 @@ class EReg {
 	}
 
 	public function replace( s : String, by : String ) : String {
-		by = Rex.gsub(by, "\\$*\\$", "%%");
+		by = Rex.gsub(by, "\\${2}", "$"); // escape double dollar signs
+		by = Rex.gsub(by, "\\$(\\d)", "%%1"); // convert dollar sign matched groups to Rex equivalent
 		return Rex.gsub(s,r,by, global ? null : 1);
 	}