Browse Source

unspec EReg.replace behavior for unknown subgroup replacements because Php does not comply

Simon Krajewski 12 years ago
parent
commit
f41bf339e8
2 changed files with 4 additions and 5 deletions
  1. 1 2
      std/EReg.hx
  2. 3 3
      tests/unit/unitstd/EReg.unit.hx

+ 1 - 2
std/EReg.hx

@@ -167,8 +167,7 @@ class EReg {
 		
 		If [by] contains [$1] to [$9], the digit corresponds to number of a
 		matched sub-group and its value is used instead. If no such sub-group
-		exists, the [$1] to [$9] string is used as is. The string [$$] becomes
-		[$].
+		exists, the replacement is unspecified. The string [$$] becomes [$].
 		
 		If [s] or [by] are null, the result is unspecified.
 	**/

+ 3 - 3
tests/unit/unitstd/EReg.unit.hx

@@ -90,10 +90,10 @@ pos.len == 2;
 
 // replace + $
 ~/href="(.*?)"/.replace('lead href="foo" trail',"$1") == "lead foo trail";
-~/href="(.*?)"/.replace('lead href="foo" trail',"$2") == "lead $2 trail";
+//~/href="(.*?)"/.replace('lead href="foo" trail',"$2") == "lead $2 trail";
 ~/href="(.*?)"/.replace('href="foo"',"$1") == "foo";
-~/href="(.*?)"/.replace('href="foo"',"$2") == "$2";
+//~/href="(.*?)"/.replace('href="foo"',"$2") == "$2";
 ~/href="(.*?)"/g.replace('lead href="foo" href="bar" trail',"$1") == "lead foo bar trail";
 ~/href="(.*?)"/g.replace('lead href="foo" href="bar" trail',"$$$1$$") == "lead $foo$ $bar$ trail";
-~/href="(.*?)"/g.replace('lead href="foo" href="bar" trail',"$$$2$$") == "lead $$2$ $$2$ trail";
+//~/href="(.*?)"/g.replace('lead href="foo" href="bar" trail',"$$$2$$") == "lead $$2$ $$2$ trail";
 #end