And yet again!
So after I wrote the preceding post about the changes to correctly get the matching groups for a RegExp, I find that it's already been fixed in the svn repository located here: https://svn.evaluant.com:8443/svn/jint
During my work with achieving proper regular expression behavior, I've found a couple spots in code where I think changes are needed. Because I'm not checking them in (I feel confident in the changes within my narrow functionality scope, do not feel
confident enough in them for all use cases), I thought I'd at least chronicle places I think require changes. I'll list them in issue/fix manner.
regular expression options that are instantiated instead of created with a literal do NOT get their regexp options processed.
ie: this worked -- var myRe = /d(b+)(d)/ig
but not this -- var myRe = new RegExp("d(b+)(d)","ig")
in JsRegExpConstructor, public override JsInstance Execute(ExecutionVisitor, JsDictionaryObject, JsInstance), I changed the return line from:
return visitor.Return(New(parameters.ToString(), false, false, false));
The "global" behavior of regular expressions is not properly working.
in JsRegExpConstructor, public JsInstance ExecImpl(JsRegExp, JsInstance), I changed the following lines:
i = 0;
i = 0;
all assigments to local variable "lastIndex" after the initial assignment should be replaced with the assignment of the "lastIndex" property hanging off the regexp object:
lastIndex = 0; and lastIndex = e;
regexp["lastIndex"] = Global.NumberClass.New(0);
and regexp["lastIndex"] = Global.NumberClass.New(e);
Making these changes appeared to enable the global functionality of Regular Expressions.