浏览代码

Lua: Ereg.split does not respect /g flag, need workaround

Justin Donaldson 9 年之前
父节点
当前提交
9e486db479
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      std/lua/_std/EReg.hx

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

@@ -104,7 +104,9 @@ class EReg {
 	}
 
 	public function split( s : String ) : Array<String> {
-		return Boot.luaIteratorToArray(Rex.split(s, r));
+		// we can't use directly s.split because it's ignoring the 'g' flag
+		var d = "#__delim__#";
+		return Boot.luaIteratorToArray(Rex.split(replace(s,d), d));
 	}
 
 	public function replace( s : String, by : String ) : String {